Is it possible to use an array in the BindParam();? i mean like this:
$stmt = $this->Db->prepare("INSERT INTO test (name,age) VALUES (:name,:age)");
$stmt->BindParam(array(":name"=>"michael",
":age"=>"21"
));
$stmt->execute();
OR Do you have to bind them 1 by 1 like:
$stmt->BindParam(":name","Michael");
$stmt->BindParam(":age","21");
$stmt->execute();
No, you cannot use an array with bindParam. In these cases, it is best to refer to the manual: http://php.net/manual/en/pdostatement.bindparam.php
However, you can use an array with execute:
$stmt = $this->Db->prepare("INSERT INTO test (name,age) VALUES (:name,:age)");
$stmt->execute(array(":name"=>"michael",
":age"=>"21"
));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments