1
Buster
Reference to returned resource id?
  • 2004/9/11 15:57

  • Buster

  • Just popping in

  • Posts: 6

  • Since: 2004/9/11


Hmm, I have often seen this code in XOOPS I dont understand really:

$connectionId =& mysql_connect(...);

// OR

$result =& mysql_query(...);

// OR

$handle =& fopen(...);
?>


Why do u want a reference to a resource id which is already a reference (better: it is an identifier which points to an entry in the referencetable)? Actually a resource id is only a number with a resourcetype like stream, so no big object you have to worry about. You can test this with intval($yourResource). So whats the magic behind it?

Samplecode from mysqldatabase.php (XOOPS):
function &queryF($sql$limit=0$start=0) {
    if ( !empty(
$limit) ) {
        if (empty(
$start)) {
        
$start 0;
        }
    
$sql $sql' LIMIT '.(int)$start.', '.(int)$limit;
    }
    [
b]$result =& mysql_query($sql$this->conn);[/b]
    if ( 
$result ) {
        
$this->logger->addQuery($sql);
    return 
$result;
    } else {
        
$this->logger->addQuery($sql$this->error(), $this->errno());
    return 
false;
    }
}
?>


Thanks for your comments! :)

.:Buster

2
Buster
Re: Reference to returned resource id?
  • 2004/9/13 15:37

  • Buster

  • Just popping in

  • Posts: 6

  • Since: 2004/9/11


Sry for the re-post but its frustrating that no one gives a lil' sign. Is the question too hard or is it unclear what I mean?

.:Buster

3
Dave_L
Re: Reference to returned resource id?
  • 2004/9/13 16:24

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


That's a good question. I don't have an answer, so I'm cross-posting it in the PHP forum.


4
Buster
Re: Reference to returned resource id?
  • 2004/9/13 18:06

  • Buster

  • Just popping in

  • Posts: 6

  • Since: 2004/9/11


Wow, thanks a lot, Dave_L! :)

.:Buster

5
Mithrandir
Re: Reference to returned resource id?

Sorry for not responding, but I have no answer to the question.

(and Dave, keep in mind that the dev forums are for module devs only, so no anonymous access )

6
Dave_L
Re: Reference to returned resource id?
  • 2004/9/13 18:28

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Oops, I forgot. I was thinking that unregistered users could read posts.

7
Buster
Re: Reference to returned resource id?
  • 2004/9/23 12:09

  • Buster

  • Just popping in

  • Posts: 6

  • Since: 2004/9/11


Hmm, is no one here who can reply to this question? I think of the XOOPS coders cause they use references to resources (e.g. streams).

.:Buster

8
Mithrandir
Re: Reference to returned resource id?

perhaps a little glitch?

I do know that it is not beneficial to use references for non-objects, but I don't know if it has too much impact.

Is it important? I mean, compared to other performance areas such as SQL query count, I cannot imagine this to be more than a very small overhead

9
Buster
Re: Reference to returned resource id?
  • 2004/9/23 14:30

  • Buster

  • Just popping in

  • Posts: 6

  • Since: 2004/9/11


No, it is not sooo important but I am very interested in how PHP handles references to resources (e.g. streams). Maybe in another way than PHP handles object references. I dunno that's why I am asking you. PHP is a very crazy programming language and unpredictable though.

.:Buster

10
Buster
Re: Reference to returned resource id?
  • 2004/11/10 19:30

  • Buster

  • Just popping in

  • Posts: 6

  • Since: 2004/9/11


Lol, no XOOPS developer knows about it? Thats a lil bit curious cause you guys have coded these modules? Oo

Sry that I am so bold atm. ^^

.:Buster

Login

Who's Online

188 user(s) are online (141 user(s) are browsing Support Forums)


Members: 0


Guests: 188


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits