2013-02-21 59 views
0

更改服務器配置後。更新MYSQL和PHP。我得到不同的SQL錯誤,像這樣的:PDO相關數據庫錯誤

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = '759'' at line 1

SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

我加入$this->dbo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);,的結果代碼中的錯誤。

我沒有改變任何代碼,所以它不能是synthax錯誤?

UPDATE: 功能loadAssoc($值= FALSE){

  // Execute statement 
      ($values) ? $this->statement->execute($values) : $this->statement->execute(); 

      // Return associative array 
      return $this->statement->fetch(PDO::FETCH_ASSOC); 
     } 

我得到的錯誤PHP的致命錯誤:調用一個成員函數的execute()在使用執行線。

在我的cPanel它說:LINUX,PHP 5.3.21和MySQL 5.5.28(剛剛升級到這個)認爲這將解決這個問題

就像我前面說的一切我的服務器更新之前工作:S

+4

請顯示完整查詢的示例。 – silkfire 2013-02-21 20:49:21

+0

嘗試使用PDO啓用緩衝查詢時顯示'代碼錯誤' – hek2mgl 2013-02-21 20:53:10

+3

第一個錯誤與PDO無關 - * *您已經編寫了*語法錯誤*查詢。 – zerkms 2013-02-21 20:54:06

回答

1

PHP documentation

If this attribute is set to TRUE on a PDOStatement, the MySQL driver will use the buffered versions of the MySQL API. If you're writing portable code, you should use PDOStatement::fetchAll() instead.

看來 - 無論什麼原因 - 已更新的PDO擴展是在MySQL API不支持緩衝查詢鏈接。

您現有的代碼使用緩衝查詢,因此它會失敗。在不改變代碼的唯一解決方案本身是:

  • 安裝支持緩衝查詢
  • 鏈接PDO對這個庫中的MySQL客戶端庫

爲了進一步幫助你,我需要更多的有關您正在使用哪個操作系統以及哪些版本的MySQL,PDO,PHP的信息...

+0

功能loadAssoc($值= FALSE){ \t \t \t \t //執行語句 \t \t \t \t($值)? $ this-> statement-> execute($ values):$ this-> statement-> execute(); \t \t \t \t //返回關聯數組 \t \t \t \t返回$這 - >陳述書>取(PDO :: FETCH_ASSOC); \t \t \t}我得到錯誤PHP致命錯誤:調用成員函數execute()在使用execute的行上。我認爲這可能是PDO鏈接到一個錯誤的mysql API(從這裏唯一的答案)。我將研究並回到我的版本的MySQL,PHP和pdo – user1828049 2013-02-21 22:08:30

+0

在我的cPanel中它說:linux,php 5.3.21,mysql 5.5。28(剛升級到這個)認爲會解決問題 – user1828049 2013-02-22 00:18:59

+0

我會問一個關於cpanel支持的問題。 (如果你還沒有) – hek2mgl 2013-02-22 00:47:32