开发者

Bug inserting multiple commands into a prepared statement

I'm working with Zend and postgres database, and I want get a result from a sql query that has inside more than one command. What I exactly want is create a table with some data and then ask for these data in a sel开发者_开发问答ect query all in the same statement.

but when it is executed, I got this bug:

ERROR: cannot insert multiple commands into a prepared statement

I have found a way to solve it inserting "/" before the second command, but it did not work.

thanks in advance for help or advices about that!


PHP PDO driver does not allow multiple SQL commands in one statement. You should try to set PDO option PDO::ATTR_EMULATE_PREPARES to true:

$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true).

Check Zend documentation for how to do it. (For example, in Yii it's done by emulatePrepare option to "db" component)


That would be more helpful if you pasted your code here as well.

I'm not sure if what you're referring to is actually a sql query. What you seem to be doing is to append a few SQL commands such as a create, an insert and a select into one prepared statement! Instead, you either need to send these commands separately or create separate prepared statements. As far as I know postgres forbids multiple SQL commands in a single prepare call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜