Page 1 of 1

finding the newest id in the database efficiently

Posted: Fri Sep 23, 2005 7:36 pm
by robster
Hi all,

I have a function that adds a client to the database. Then, I want to extract that clients ID from mysql (using php). I want this the moment after the client has been added.

What is the most efficient way to do this? Currently I am parsing through the WHOLE database, taking the ID, then when I get to the last client, I have the latest ID. It's aweful ;)

Any suggestions appreciated.

Rob

Posted: Fri Sep 23, 2005 7:38 pm
by feyd

Posted: Fri Sep 23, 2005 7:46 pm
by robster
amazing! I'm going through this 'all excited about learning' stage and this whole php/mysql thing is really making sense to me now.

This function (and its implimentation) is a great example of elegance over my clutzy learning stage that I'm pulling out of.

Thanks so much for that link.


rob