我试图使用此代码提取一些值:
主要// refhls : array
foreach($refhls as $refhl){
$abc = $this->getArrayIntervenants($refhl);
}
函数public function getArrayIntervenants($refhl){
$requete = $this->bdd->bd->prepare('SELECT intervenant FROM detailsfiche WHERE ref_hl = :ref_hl');
$requete->bindValue(':ref_hl', $refhl, PDO::PARAM_INT);
$requete->execute(); // -----MARKED LINE-----
return $requete->fetchAll(PDO::FETCH_ASSOC);
}
这样做,我得到这个错误信息在标记行:
注意:第138行file.php中数组到字符串的转换
由于变量$refhl是一个数组,因此不能直接将其绑定进去。在函数的开头调用var_dump将会对您有所帮助。
var_dump ($ refhl);
你可以这样替换你的行:
$requete->bindValue(':ref_hl', $refhl['myArrayKey'], PDO::PARAM_INT);
$refhl是一个数组。不能将数组用作字符串。
尝试通过
检查数组中的字符串isset($refh1[$positionKey]) { }
,如果该值存在,则使用它!