PDA

View Full Version : these shitty sql warnings


ReD_HunTeR
04/05/2016, 12:51 PM
EDIT: Solved

jlalt
04/05/2016, 12:59 PM
Show your
new MySQLPipeline;

ReD_HunTeR
04/05/2016, 01:15 PM
got these errors in this shity 'gates' table, not anywhere else :/

Konstantinos
04/05/2016, 01:27 PM
MySQLPipeline should have a tag of DB: when it is declared.

Are you trying to convert MySQL to SQLite? Having "MySQL" in variable name but using sqlite functions.

ReD_HunTeR
04/05/2016, 01:36 PM
ye, konstantinos
i'm trying to convert SQLite to MySQL :P

PrO.GameR
04/05/2016, 02:00 PM
Do you see the trend here? whenever you use MySQLPipeline you see a tagmismatch warning, which well .. tells you it doesn't match the tag, so match it for god's sake(sqlite's tag for connection is DB).

ReD_HunTeR
04/05/2016, 02:03 PM
can you help me to conver this into mysql? ill do others myself..

new Query[250],DBResult:Result,gateid = 0;
for(new i = 0; i < MAX_GATES; i++)
{
format(Query, sizeof(Query),"SELECT * FROM gates WHERE ID = %d",i);
Result = db_query(MySQLPipeline, Query);
if(db_num_rows(Result))
{
format(Query, sizeof(Query),"UPDATE `gates` SET `ID` = '%d' WHERE `ID` = '%d'",gateid,i);
db_query(MySQLPipeline, Query);
gateid ++;
}
}

Konstantinos
04/05/2016, 02:17 PM
Oh, it was the other way around.

I'm trying to figure out what your code is supposed to do - are you trying to set the IDs again without the missing numbers (perhaps those that were deleted)? Having set auto increment for a table is always good, so don't worry if you delete some of the rows and you see the IDs as the following: 1, 2, 6, 7, 10 etc.

ReD_HunTeR
04/05/2016, 02:23 PM
yes you're right konstantinos, so how can i fix those warnings?

Konstantinos
04/05/2016, 02:38 PM
// global:
new gateid;

// calling it once to fix them for now
new Query[50];
for (new i = 0; i < MAX_GATES; i++)
{
format(Query, sizeof(Query), "SELECT * FROM gates WHERE ID = %d LIMIT 1", i);
mysql_tquery(MySQLPipeline, Query, "OnGateLoad", "ii", gateid, i);

gateid++;
}

forward OnGateLoad(gate_id, _i);
public OnGateLoad(gate_id, _i)
{
if (cache_get_row_count())
{
new Query[45];
format(Query, sizeof(Query), "UPDATE gates SET ID = %d WHERE ID = %d", gate_id, _i);
mysql_tquery(MySQLPipeline, Query, "", "");
}
return 1;
}

ReD_HunTeR
04/05/2016, 03:29 PM
EDIT: Solved

Konstantinos
04/05/2016, 04:22 PM
Select all the data from the table with only 1 query:

mysql_tquery(MySQLPipeline, "SELECT * FROM gates", "LoadGates", "");

forward LoadGates();
public LoadGates()
{
for (new i, j = cache_get_row_count(); i != j; ++i)
{
if (i >= sizeof GateInfo) return print("Max limit of gates was reached. Increase for more.");

GateInfo[i][GID] = cache_get_field_content_int(i, "ID");

...
}
return 1;
}


Don't forget that rowid is "i" and:

http://wiki.sa-mp.com/wiki/MySQL/R33#cache_get_field_content
http://wiki.sa-mp.com/wiki/MySQL/R33#cache_get_field_content_int
http://wiki.sa-mp.com/wiki/MySQL/R33#cache_get_field_content_float

ReD_HunTeR
06/05/2016, 10:30 AM
thanks alot @Konstantinos