简体   繁体   English

将Pear DB站点迁移到mdb2,返回语法错误

[英]migrating a Pear DB site to mdb2, syntax error returned

I'm updating a lot of old methods, but I've got stuck with this line 我正在更新许多旧方法,但是我对这条线卡住了

$res =& $mdb2->query($mdb2->prepare("SELECT * FROM book WHERE id = ?"), array($sql_id));

I was getting a message in the error log saying PHP Fatal error: Call to undefined method MDB2_Error::numRows() 我在错误日志中收到一条消息,提示PHP致命错误:调用未定义的方法MDB2_Error :: numRows()

So I added this line 所以我添加了这一行

if (PEAR::isError($res)) { die($res->getMessage().' ::: '.$res->getUserInfo()); }

to see what was causing the error and I get this back to the screen 看看导致错误的原因,然后我将其返回屏幕

MDB2 Error: syntax error ::: _doQuery: [Error message: Could not execute statement] [Last executed query: MDB2 Error: syntax error] [Native code: 1064] [Native message: 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 'MDB2 Error: syntax error' at line 1] 

I'm not sure what's wrong with the query, it looks ok to me? 我不确定查询出了什么问题,对我来说看起来还好吗?

在这里,无需执行PREPARE部分。

 $res =& $mdb2->query("SELECT * FROM book WHERE id = '" . $sql_id . "' " );

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

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