-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
Description
In PDO it's common to also provide an associative array of variables in the form of ":name", as well as question mark placeholders. (http://php.net/manual/en/pdostatement.bindparam.php)
So it would be awesome if $query->bindParamsFromArray($args); also supported this.
// Example:
$stmt = 'update table set foo=:bar, foo2=:bar2 where id=:id';
$args = array(':bar'=>'my value',':bar2'=>"my \"second\" value", ':id'=>123);
// or without semicolons:
$args = array('bar'=>'my value', 'bar2'=>"my \"second\" value", 'id'=>123);
// Desired result:
update table set foo='my value', foo2='my "second" value' where id=123
// Potential error in case of mismatching
// SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
WyriHaximus, AllenJB, clue, tonix-tuft and pfk84