Jump to content

PDOStatement::bindParam versus PDOStatement::bindValue


ravinggenius

Recommended Posts

  • 1 year later...

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');

 

;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.