2013-07-06 43 views
1

查詢(如回顯)PDO的Mysql erorr 1064

DELETE * FROM BlogPosts WHERE Id=? 

Fatal error: Uncaught exception 'PDOException' with message '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 '* FROM BlogPosts WHERE Id='6'' at line 1' in /usr/www/maxtingle/Blog/System/Core/Functions.php:177 Stack trace: #0 /usr/www/maxtingle/Blog/System/Core/Functions.php(177): PDOStatement->execute(Array) #1 /usr/www/maxtingle/Blog/System/Core/BlogPost.php(201): Functions\Database->Delete('*', 'Id=?', Array) #2 /usr/www/maxtingle/Blog/System/Blog.php(102): BlogPost->Delete() #3 [internal function]: Blog::DeletePost('6') #4 /usr/www/maxtingle/Blog/index.php(52): call_user_func_array(Array, Array) #5 {main} thrown in /usr/www/maxtingle/Blog/System/Core/Functions.php on line 177 

回答

2

DELETE一個總是刪除整個行,所以指定字段以刪除該錯誤是沒有意義的。

你想:

DELETE FROM BlogPosts WHERE Id=? 
+0

抱歉,我碰上意外保存刪除'*'之前 - 固定。 –

+0

+1 b/c都回答,但你提出了邏輯。 –

2

你不需要*,刪除整行:

DELETE FROM BlogPosts WHERE Id=?

+0

謝謝,工作完美 – user1763295