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"
));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.