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********************//}再次阅读我发现的手册时:PDO->closeCursor我应该将其放置在标记的地方吗?它是可选的/自动调用的吗?似乎只有某些驱动程序需要它.在不需要/不支持它的驱动程序上调用它会导致错误吗? MySQL怎么样?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?推荐答案这里的重复出现" bindParam()并不是必须的: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}在没有结果集时(即仅使用SELECT或过程将结果返回),您不需要closeCursor(),但是通常我已经在上一条语句/行中的某处完成了fetchAll.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. 这篇关于PDO-> bindParam,PDO-> bindValue和PDO-> closeCursor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-26 07:15
查看更多