Best way to save houses to MySQL
#1

This doesn't work but what would be the best way to save all house information?

pawn Код:
stock SaveHouses()
{
    new query[500], rows, fields;
    cache_get_data(rows, fields, g_Handle);

    new id = 0;
    if(rows)
    {
        while(id <= rows-1)
        {
            format(query, sizeof(query), "UPDATE `Houses` SET `HouseID` = %d, `Address` = '%s', `Price` = %d, `EnterX` = %f, `EnterY` = %f, `EnterZ` = %f, `EnterA` = %f, `ExitX` = %f, `ExitY` = %f, `ExitZ` = %f, `ExitA` = %f, `Interior` = %d, `Type` = %d WHERE `HouseID` = %d",
            HouseInfo[id][hHouseID],
            HouseInfo[id][hAddress],
            HouseInfo[id][hPrice],
            HouseInfo[id][hEnterPos][0],
            HouseInfo[id][hEnterPos][1],
            HouseInfo[id][hEnterPos][2],
            HouseInfo[id][hEnterPos][3],
            HouseInfo[id][hExitPos][0],
            HouseInfo[id][hExitPos][1],
            HouseInfo[id][hExitPos][2],
            HouseInfo[id][hExitPos][3],
            HouseInfo[id][hInterior],
            HouseInfo[id][hType]
            );
           
            mysql_function_query(g_Handle, query, false, "", "");
            id ++;
        }
    }
    return 1;
}
Reply
#2

First, you can use a for(each) loop instead of a while.

Secondly, a 500 chars query isn't very useful. 256 will most likely suffy in your case.

I think that's all I can tell for now, but I'm pretty tired, I may have missed something to optimize.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)