Re: Creating alphanumeric id for a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I assume that I can get increment value/sequence from db  (I used harcoded
> increment value  in the code above (generate_id(1))),
> but I don't know how I can get this incremental value from db.I use mysql
> 5.0.

If you're thinking of retrieving the newest value of an AUTO_INCREMENT
column, immediately after inserting a row, there are different ways to
do this depending on how you're connecting to MySQL.

PDO, for example, has a method called lastInsertId():
http://us2.php.net/manual/en/pdo.lastinsertid.php

And the mysql_* family of functions has mysql_insert_id(), etc.

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux