Page 1 of 1

mysql connection & resource types

Posted: Fri Nov 11, 2005 12:18 pm
by Luke

Code: Select all

$link_id = @mysql_query($sql);
What would be the benefit of storing this in $link_id... what can you do with that variable??

Posted: Fri Nov 11, 2005 12:21 pm
by Charles256

Code: Select all

if (!$link)
{
   echo "uh oh. this did not work..damn..";
}
else
{
   echo "yay.it worked.";
}

Posted: Fri Nov 11, 2005 12:58 pm
by Luke
Why not just do this...

Code: Select all

if(mysql_query($sql)){
    //yay it worked
}
else{
    //damn I suck
}
I am wondering what the benefit is of doing it the other way as opposed to this.

Posted: Fri Nov 11, 2005 1:03 pm
by foobar

Code: Select all

function mybooleanfunc () {

  if (rand() > 0.5) return true;
  else return false;
}

/************************/

if (mybooleanfunc()) echo "yes";
else echo "no";

//is equivalent to:

$foo = mybooleanfunc();

if ($foo) echo "yes";
else echo "no";
No difference. Just look at what's happening in the code.

Posted: Fri Nov 11, 2005 1:15 pm
by redmonkey
Without a resource link indentifier, you will have no way of discovering stats for your query. i.e. Issue a select query then tell me how many rows are in that select query?

Posted: Fri Nov 11, 2005 1:30 pm
by Luke
redmonkey wrote:Without a resource link indentifier, you will have no way of discovering stats for your query. i.e. Issue a select query then tell me how many rows are in that select query?
Thank you.