Image

Imagem00t wrote in Imagephp

PEAR DB question...

Is it possible to execute multiple SQL statements (inserts and a select) using PEAR DB?

for example:
$SQL = "insert into table (id, cur_ver, status) values (1, 0, 'a');";
$SQL .= " insert into table_ver (table_id, ver_num, name, status) values (LAST_INSERT_ID(), 0, \"blah\", 'a');";
$SQL .= " select LAST_INSERT_ID() as lastid;";

$blah = $DB->Query($SQL);

PHPmyadmin accepts it and returns valid information, but PEAR chokes on it with a DB Syntax Error. I know PHPmyadmin does some fiddling behind the scenes with the queries, but to what extent I don't know.

Mostly I'm concerned with concurrent inserts to the DB screwing up the LAST_INSERT_ID() call and would prefer not to have to wait for control to return to php after each insert before the select.

Any help would be appreciated, thanks!