ravinggenius Posted August 27, 2008 Share Posted August 27, 2008 Is there any kind of rule as to which one I should use? Can anybody explain the differences to me? Link to comment https://forums.phpfreaks.com/topic/121591-pdostatementbindparam-versus-pdostatementbindvalue/ Share on other sites More sharing options...
ridiculous Posted August 27, 2008 Share Posted August 27, 2008 I just started working with PDO the other day and went through this. I don't think there is any kind of performance difference between the two...just that one is more spelled out in appearance than the other. Link to comment https://forums.phpfreaks.com/topic/121591-pdostatementbindparam-versus-pdostatementbindvalue/#findComment-627147 Share on other sites More sharing options...
ravinggenius Posted August 28, 2008 Author Share Posted August 28, 2008 I haven't been able to tell a difference, but I'm using bindParam for UPDATE or INSERT values and bindValue for WHERE clauses. Hopefully that's what the developers had in mind.... Link to comment https://forums.phpfreaks.com/topic/121591-pdostatementbindparam-versus-pdostatementbindvalue/#findComment-627526 Share on other sites More sharing options...
mtarroyo Posted May 27, 2010 Share Posted May 27, 2010 If you use PDOStatement::bindParam() to replace the parameter marks, the variables are passed by reference and if there are any return value, they will fill the variables. So, you can pass only variable containers. Like this: $stmt->bindParam(1, $name); Because strings cannot be passed by reference. Using PDOStatement::bindValue() the values are not passed by reference and you can do things like that: $stmt->bindValue(1, 'Mario'); Link to comment https://forums.phpfreaks.com/topic/121591-pdostatementbindparam-versus-pdostatementbindvalue/#findComment-1064109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.