繁体   English   中英

PDO Mysql erorr 1064

[英]PDO Mysql erorr 1064

查询(As echo'd)

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

DELETE总是删除整行,因此指定要删除的字段毫无意义。

你要:

DELETE FROM BlogPosts WHERE Id=?

你不需要* ,你删除整行:

DELETE FROM BlogPosts WHERE Id=?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM