PDO执行:Array to String转换

时间:2014-08-03 12:11:13

标签: php pdo

我收到一个Array to String转换错误

errorCode() - > 00000

errorInfo() - >阵列

public function getUserInfoByMail( $userEmail )
{
    if (is_mail($userEmail))
    {
        $sql = $this->db->prepare("SELECT * FROM customer INNER JOIN addresses ON customer.customerid = addresses.customerid WHERE standard='1' AND deleted='0' AND email=:email");
        if ($sql->execute(array(':email' => $userEmail))) 
             return $sql->fetch(PDO::FETCH_ASSOC);
        else 
             throw new Exception("There was a DB-Error!");
    }
    //....
}

为什么我收到Array to String转换错误?

2 个答案:

答案 0 :(得分:1)

->execute() expects you to send it an array with each element representing each ? in the query.\

问题的主要原因是只发送2个元素,所以它使用数组作为第二个...请参阅here

答案 1 :(得分:0)

错误代码00000表示您没有错误。只是尝试将errorCode转换为int,它将评估为false