What is the equivalent of bind_result on PDO

后端 未结 4 1964
无人共我
无人共我 2020-12-07 02:06

I\'m converting to PDO and Im using prepared statements, I want to bind my result as so $stmt->bind_result($email_count); so i am able to put this into an if

4条回答
  •  渐次进展
    2020-12-07 02:27

    Here's my custom function:

    function bindColumns($stmt, $columns){
        if(!is_array($columns)) $columns=array($columns);
        $count=count($columns);
        for($i=0;$i<$count;$i++) $stmt->bindColumn($i+1, $columns[$i]);
    }
    

    And usage (variables by reference):

    bindColumns($stmt, array(&$worker_id, &$password, &$salt));
    

提交回复
热议问题