[TYPO3-dev] MySQL LAST_INSERT_ID() returns 0, different connection???

Christoph Kunze bruce at anjardis.de
Tue Feb 14 08:41:21 CET 2006


Hi Andreas,
I always store the value of $GLOBALS['TYPO3_DB']->sql_insert_id() in a 
variable and then use it for further (mm-)inserts. Maybe it works that 
way...?

Andreas Förthner schrieb:
> Hi list,
> 
> I just tried to fill a table and its mm-table with the right ids. I 
> insert the values in the main table and then I try to insert the 
> mm-relation, for that reason I need the id of the inserted record. I 
> tried that with the LAST_INSERT_ID() function in mysl, but it seems to 
> return always 0. As far as I know it only will return the id if the two 
>  insert-statements are in the same database connection... Is it possible 
> that TYPO3 opens an new connection for each query?
> 
> Does anybody know a solution for that problem? How do you fill mm-tables 
> usually?
> 
> Thank you for your help...
> 
> Regards
> 
> Andreas




More information about the TYPO3-dev mailing list