|
Seems like you did not quite understand me. I said RETURN last insert id. Not just use it. I am not completely stupid.
Let me give you an example of what I need. Код:
stock foo() {
mysql_query(...);
...
return mysql_insert_id();
}
main() {
printf("Last insert ID: %d", foo());
}
--- Yeah I know the code makes no sense. But that is just an example. I use returns in more complex scripts. I want everything organized and good. This threaded-only stuff just makes me write bad, disorganized code. |
|
How to use mysql_insert_it( ); on R7 or above ?
I have this code: Код:
format( gsQuery, 512, "INSERT INTO `Clans` VALUES(0,'%s','%s','1','%.3f','%.3f','%.3f','%.3f','0','0','0','0','0','0','0','0','0','0')", clanname, PlayerName( playerid ), c_Pos[ 0 ], c_Pos[ 1 ], c_Pos[ 2 ], c_Pos[ 3 ] ); mysql_function_query( g_Handle, gsQuery, false, "", "" ); PlayerInfo[ playerid ][ ID ] = mysql_insert_id( g_Handle ); printf( "ClanID: %d", PlayerInfo[ playerid ][ ID ] ); |
[00:48:33] Error: Function not registered: 'mysql_debug' [00:48:33] Error: Function not registered: 'mysql_connect' [00:48:33] Error: Function not registered: 'mysql_set_charset' [00:48:33] Error: Function not registered: 'mysql_function_query' [00:48:33] Error: Function not registered: 'mysql_close' [00:48:33] Error: Function not registered: 'mysql_num_rows' [00:48:33] Error: Function not registered: 'mysql_free_result' [00:48:33] Error: Function not registered: 'mysql_real_escape_string' [00:48:33] Error: Function not registered: 'mysql_num_fields' [00:48:33] Error: Function not registered: 'cache_get_data' [00:48:33] Error: Function not registered: 'cache_get_row' [00:48:33] Script[gamemodes/samp2k13.amx]: Run time error 19: "File or function is not found"
Good job
The problem is I downloaded a wrong libmysql.dll(link in the main post is down, so I ******d).
|
Reupload: http://dl-it.tk/ul-8b5k
|
stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[])
{
new Query[128], Float:sqlfloat;
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(Query, sizeof(Query), "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_function_query(MYSQLConnection,Query,true,"QueryFinished","");
mysql_store_result();
mysql_fetch_float(sqlfloat);
mysql_free_result();
return sqlfloat;
}
|
Hey,
Which Command can I use for Get float in R7? Code:
stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[])
{
new Query[128], Float:sqlfloat;
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(Query, sizeof(Query), "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_function_query(MYSQLConnection,Query,true,"QueryFinished","");
mysql_store_result();
mysql_fetch_float(sqlfloat);
mysql_free_result();
return sqlfloat;
}
Any ideas ![]() |
/**
* Copyright © 2013 - Dan
* All rights reserved.
*/
// Gets an int from the MySQL result using a field name.
stock mysql_fetch_field_row_int(fieldname[], connectionHandle) {
new ret[64];
mysql_fetch_field_row(ret, fieldname, connectionHandle);
return strval(ret);
}
// Gets a float from the MySQL result using a field name.
forward Float:mysql_fetch_field_row_float(fieldname[], connectionHandle);
stock Float:mysql_fetch_field_row_float(fieldname[], connectionHandle) {
new ret[64];
mysql_fetch_field_row(ret, fieldname, connectionHandle);
return floatstr(ret);
}
// Gets an int from the cache using a field ID.
stock cache_get_row_int(row, idx, connectionHandle) {
new ret[64];
cache_get_row(row, idx, ret, connectionHandle, sizeof(ret));
return strval(ret);
}
// Gets a float from the cache using a field ID.
forward Float:cache_get_row_float(row, idx, connectionHandle);
stock Float:cache_get_row_float(row, idx, connectionHandle) {
new ret[64];
cache_get_row(row, idx, ret, connectionHandle, sizeof(ret));
return floatstr(ret);
}
// Gets an int from the cache using a field name.
stock cache_get_field_content_int(row, const fieldname[], connectionHandle) {
new ret[64];
cache_get_field_content(row, fieldname, ret, connectionHandle, sizeof(ret));
return strval(ret);
}
// Gets a float from the cache using a field name.
forward Float:cache_get_field_content_float(row, const fieldname[], connectionHandle);
stock Float:cache_get_field_content_float(row, const fieldname[], connectionHandle) {
new ret[64];
cache_get_field_content(row, fieldname, ret, connectionHandle, sizeof(ret));
return floatstr(ret);
}