#50171 [Opn->Csd]: Code behaviour different from documentation

From: Date: Sat, 14 Nov 2009 15:43:47 +0000
Subject: #50171 [Opn->Csd]: Code behaviour different from documentation
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3161@lists.php.net to get a copy of this message
ID: 50171 Updated by: vrana@php.net Reported By: rapsys at free dot fr -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: debian lenny/sid PHP Version: 5.2.11 New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2009-11-13 23:13:21] rapsys at free dot fr On this page : http://www.php.net/manual/en/function.mysql-insert-id.php The documentation say (for what i understand) that if you do a successfull insert, and later many request, when you call last_insert_id it will return the insert_id of the last successfull insert (even if there have been many request between). Example : connect (success) insert query (success) select query (success) insert query (failed) If you follow what say the doc, now mysql_insert_id should return first insert id, but in reality it will return 0 cause last request has failed. ------------------------------------------------------------------------ [2009-11-13 19:33:26] vrana@php.net I can't see anything wrong with the documentation. ------------------------------------------------------------------------ [2009-11-13 19:04:30] rapsys at free dot fr The note paragraph should be changed too. ------------------------------------------------------------------------ [2009-11-13 19:03:30] rapsys at free dot fr Description: ------------ This documentation don't work anymore for mysql inserted id function. «The ID generated for an AUTO_INCREMENT column by the previous INSERT query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established.» Right now the behaviour has changed, the mysql_inserted_id return alway 0 if last query on the connexion was an update, delete, select or a failed query. Tested on php 5.2.4 and the code behaviour is documented in mysqli function, so the documentation should be wrong since few versions Reproduce code: --------------- --- From manual page: function.mysql-insert-id#Notes --- Code : connect to db query with a working insert see x as inserted id query a update see 0 as inserted id query a failed insert see 0 as inserted id Expected result: ---------------- The value of the AUTO_INCREMENT field that was updated by the previous query. Returns zero if there was no previous query on the connection or if the query did not update an AUTO_INCREMENT value. Behaviour changed in php version X.Y.Z Actual result: -------------- The ID generated for an AUTO_INCREMENT column by the previous INSERT query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50171&edit=1

« previous php.doc.bugs (#3161) next »