SA-MP Forums Archive
[Mysql] Faster loading - 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] Faster loading (/showthread.php?tid=426567)



[Mysql] Faster loading - Dj_maryo1993 - 29.03.2013

So at the moment im using this
pawn Код:
public LoadSQLCar(sqlid)
{
    new query[128];
    new value[32];
    new wholeline[1024];
    format(query, sizeof(query), "SELECT * FROM `vehicles` WHERE `id` = '%d' LIMIT 1", sqlid);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(wholeline);
    ///-----
    sscanf(wholeline, "p<|>iis[20]iiffffiiid",value,CarInfo[sqlid][Owned],CarInfo[sqlid][Owner],CarInfo[sqlid][Faction],CarInfo[sqlid][Model],CarInfo[sqlid][Cx],CarInfo[sqlid][Cy],CarInfo[sqlid][Cz],CarInfo[sqlid][Inc],CarInfo[sqlid][C1],CarInfo[sqlid][C2],CarInfo[sqlid][JobVehicle],CarInfo[sqlid][Price]);
    printf("%d,%d,%s,%d,%d,%f,%f,%f,%d,%d,%d,%d",value,CarInfo[sqlid][Owned],CarInfo[sqlid][Owner],CarInfo[sqlid][Faction],CarInfo[sqlid][Model],CarInfo[sqlid][Cx],CarInfo[sqlid][Cy],CarInfo[sqlid][Cz],CarInfo[sqlid][Inc],CarInfo[sqlid][C1],CarInfo[sqlid][C2],CarInfo[sqlid][JobVehicle]);
    AddStaticVehicleEx(CarInfo[sqlid][Model],CarInfo[sqlid][Cx],CarInfo[sqlid][Cy],CarInfo[sqlid][Cz],CarInfo[sqlid][Inc],CarInfo[sqlid][C1],CarInfo[sqlid][C2],8000000);
    mysql_free_result();
}
But someone told me that you can load all the cars in one query , instead of query-ing each vehicle


Re: [Mysql] Faster loading - CoaPsyFactor - 29.03.2013

of course it is faster to call one huge query than dozen of little queries


Re: [Mysql] Faster loading - Dj_maryo1993 - 29.03.2013

Yes , but how do i query the whole table ?


Re: [Mysql] Faster loading - CoaPsyFactor - 30.03.2013

Код:
SELECT * FROM `vehicles`;
and then just do while(mysql_fetch_row_format()) to read row by row and with sscanf store results