SA-MP Forums Archive
mysql r33 get last AI - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql r33 get last AI (/showthread.php?tid=592391)



mysql r33 get last AI - Dusan01 - 24.10.2015

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


Re: mysql r33 get last AI - Dusan01 - 25.10.2015

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;




Re: mysql r33 get last AI - Vince - 25.10.2015

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().


Re: mysql r33 get last AI - Dusan01 - 25.10.2015

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