So far I have been using PDO->bindParam
however while reading the manual I found PDO->bindValue
from what I can tell PDO->bindValue
passes by value where as PDO->bindParam
passes by reference, is this the only difference?
$modThread = db()->prepare("UPDATE `threads` SET `modtime` = UNIX_TIMESTAMP( ) WHERE `threadid` =:id LIMIT 1");
while(something)
{
$modThread->bindParam(':id', $thread);
$modThread->execute();
//*******************HERE********************//
}
Again while reading the manual I found: PDO->closeCursor
should I place it where marked? Is it optional/automatically called? Seems only certain drivers need it. Will calling it on a driver that doesn't need/support it cause errors? How about MySQL?
The 'recurring' bindParam()
here is not really necessary:
$thread = 0;
$modThread->bindParam(':id', $thread);
while($thread < 20)
{
$thread++;
$modThread->execute(); //executing with the new value, which you couldn't do with bindValue
}
You don't need a closeCursor()
when there is no resultset (i.e, only with SELECT
s or procedures giving results back) , but usually I've already done a fetchAll somewhere in a previous statement / row.