PHP PDO bindParam was falling in a foreach

前端 未结 3 1197
旧时难觅i
旧时难觅i 2020-12-05 03:15

I had a loop like that :

foreach($Fields as $Name => $Value){
    $Query->bindParam(\':\'.$Name, $Value, PDO::PARAM_STR);
}

Nothing c

3条回答
  •  清歌不尽
    2020-12-05 03:44

    There is one more nasty option to get rid of this issue.

    You can simply iterate through the array keys, and get each value as a parameter by using these keys:

    foreach(array_keys($params) as $key) {
        $sth->bindParam($key, $params[$key]);
    }
    

提交回复
热议问题