NYCPHP Meetup

NYPHP.org

[nycphp-talk] mysql_insert_id Strangeness

Hans Zaunere hans at nyphp.org
Tue Aug 5 17:28:24 EDT 2003



Analysis & Solutions wrote:
> Hey Folks:
> 
> On Tue, Aug 05, 2003 at 11:20:26AM -0400, Carlos A Hoyos wrote:
> 
>>It's safer to check the return value of mysql_query in this case (will
>>return false if insertion fails).

True.  But doing a type-strict comparision on the query itself, seems, well strange somehow.

> Yep.  When mysql_query() fails, I check the value of mysql_errno().  Error 
> numbers 1022 and 1062 have to do with duplicate keys on (if I recall 
> correctly) primary keys and duplicate keys (or if I recall incorrectly, 
> insert vs update queries).

Absolutely; I'll use mysql_errno() when I really need to keep things in line, but I'm almost positive the mysql_insert_id() trick works (or worked).  Especially since it's documented that way.

Oh well.  Still fishing on mysql's lists,

H





More information about the talk mailing list