我正在使用PDO對象在php中執行查詢。我的PDO獲取列函數中的錯誤
$stmt = $this->db->prepare('select email from users where email = :email');
return (bool) $stmt->execute(array(':email' => $email))->fetchColumn();
我在這裏得到錯誤。
Fatal error: Call to a member function fetchColumn() on a non-object
請問有什麼問題請幫忙,$this->db->query()
命令有效。
感謝
嗨如果我添加fetchcolumn()那麼它給我錯誤,因爲在問題請檢查 – XMen 2010-12-10 09:51:45
http://php.net/manual/en/pdostatement.execute.php - 執行返回布爾。如果你想訪問結果,你應該在新行中鍵入:'返回$ stmt-> fetchColumn()' – Maurycy 2010-12-10 09:56:13