24.10.2015, 09:14
Hi guys, im using mysql r33 so how can i get witch number should now go on my primary key where is enabled AI
stock getLastID(what[], &var) {
mysql_format(MySQL, Query, sizeof(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(0, 0);
}
return 1;
}
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().
|