PDA

View Full Version : Mysql update R7


Larry123
24/02/2014, 02:20 PM
So i have this code. It should update my car stats

UpdateCarFlo(car, "PosX", CarInfo[car][PosX]);
UpdateCarFlo(car, "PosY", CarInfo[car][PosY]);
......


public UpdateCarFlo(sCarId, sValue[], Float:sFlo)
{
new query[140];
format(query, sizeof(query), "UPDATE scriptcars SET %s = %f WHERE ID = %d", sValue, sFlo, sCarId);
mysql_function_query(gSQL, query, false, "SendQuery", "");
}

But i got the problem, it only updates the first public. As i can see from mysql_log:

[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] Passing query UPDATE scriptcars SET PosX = 664.403991 WHERE ID = 0 |
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] ProcessQueryThread(SendQuery) - Query was successful. (UPDATE scriptcars SET PosX = 664.403991 WHERE ID = 0)
[17:13:42] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )
[17:13:42] >> mysql_query_callback( Connection handle: 1 )



What could be the problem?

Misiur
24/02/2014, 02:29 PM
I can't help you on that one, as I don't know bugs fixed since R7. However I'd really, really reconsider that approach. Remember that call to database is one of the most expensive things your script can do. Firing one after another, while you could use single, but nicely written query is not a good idea. And if for any reason you do things like that, at least use a transaction.

Larry123
24/02/2014, 04:08 PM
Can someone help me then? How to fix it?