mysql r33 get last AI
#1

Hi guys, im using mysql r33 so how can i get witch number should now go on my primary key where is enabled AI
Reply
#2

Done, i used this code:
PHP код:
stock getLastID(what[], &var) {
    
mysql_format(MySQLQuerysizeof(Query), "SELECT MAX(ID)+1 FROM `%s`",what);
    
mysql_query(MySQL,Query);
    new 
rows cache_get_row_count();
    if(
rows) {
        var = 
cache_get_row_int(00);
    }
    return 
1;

Reply
#3

Uh, what? The whole point of using auto increment is to generate a unique ID automatically. In an insert statement the ID column need not be specified, or it can be filled with default or null in which case it will also generate a unique ID. The generated value can be retrieved with cache_insert_id().
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Uh, what? The whole point of using auto increment is to generate a unique ID automatically. In an insert statement the ID column need not be specified, or it can be filled with default or null in which case it will also generate a unique ID. The generated value can be retrieved with cache_insert_id().
Oh yeah i know that, but on loading systems from some reasons want to know what is last AI generated

but i did not know about cache_insert_id, so TNX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)