multi_query "Commands out of sync" after Insert

multi_query "Commands out of sync" after Insert

am 12.01.2008 02:58:13 von JH

I wouldn't think there would be a result set from a mysqli multi_query
when the query is a group of insert statements (there is no
auto_increment column), but I get a "commands out of sync" error on my
next query.

Originally, I had:

foreach ( . . . .
$sql. = "insert into psc (pid, lft, rgt) values
($pid, $lft, $rgt);";
}
if(!$mysqli->multi_query($sqlgeo)) {
echo $mysqli->error;
}
. . . [next sql statement, which fails with the "commands out of
sync" error]

Now, the only solution I've found is to change my simple multi_query to:

if($mysqli->multi_query($sqlgeo)) {

do{if($result=$mysqli->store_result()){$result->close();}}
while($mysqli->next_result());
}else{
echo $mysqli->error;
}


It seems like there should be a better solution than my current one?

Thanks for any suggestions,

Jeff

Using PHP 5.2.3, MySQL standard-5.0.27 on Debian Etch

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: multi_query "Commands out of sync" after Insert

am 12.01.2008 13:20:51 von Holografix

J. Hill escreveu:
> I wouldn't think there would be a result set from a mysqli multi_query
> when the query is a group of insert statements (there is no
> auto_increment column), but I get a "commands out of sync" error on my
> next query.
>
> Originally, I had:
>
> foreach ( . . . .
> $sql. = "insert into psc (pid, lft, rgt) values ($pid,
> $lft, $rgt);";
> }
> if(!$mysqli->multi_query($sqlgeo)) {
> echo $mysqli->error;
> }
> . . . [next sql statement, which fails with the "commands out of
> sync" error]
>
> Now, the only solution I've found is to change my simple multi_query to:
>
> if($mysqli->multi_query($sqlgeo)) {
> do{if($result=$mysqli->store_result()){$result->close();}}
> while($mysqli->next_result());
> }else{
> echo $mysqli->error;
> }
>
>
> It seems like there should be a better solution than my current one?
>
> Thanks for any suggestions,
>
> Jeff
>
> Using PHP 5.2.3, MySQL standard-5.0.27 on Debian Etch


Hi
Take a look here: http://www.rooftopsolutions.nl/article/173

An empty result set may cause the error.

Beste regards
holo

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php