Re: setting SQL variable
| From: | OKi98 | Date: | Fri, 19 Jan 2007 09:41:47 +0000 |
| Subject: | Re: setting SQL variable | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42960@lists.php.net to get a copy of this message | ||
marga wrote:
Is not possible to use mysql_insert_id() and assing it in a php variable, because mysql_insert_id() is executed after the COMMIT, I think. wrong, it is possible to use mysql_insert_id() during the transaction.the code should look like this: mysql_query("start transaction"); if (mysql_query(insert into first table)) { $id=mysql_insert_id(); if (!mysql_query(subsequent inserts)) $error=1; } else $error=1; mysql_query((isset($error)) ? "rollback" : "commit");