MySQL R7 problem
#1

Hello,

Today I decided to convert my script to MySQL Plugin R7 (BlueG). As you know I had to change all queries to the new ones. After doing this, the script compiled fine. But nothing loads. No houses. No map icons. Nothing! I'll post my house loading as an example.

The stock in OnGameModeInit

pawn Код:
stock LoadHouses()
{
    for(new h; h < MAX_HOUSES; h ++)
    {
        mysql_format(1,QueryString,"SELECT * FROM `HouseInfo` WHERE `ID` = %d",h);
        mysql_function_query(1,QueryString,true,"LoadHouses_PerID","i",h);
    }
}
The public LoadHouses_PerID
pawn Код:
public LoadHouses_PerID(h)
{
    new rows,fields;
    cache_get_data(rows,fields);
    if(rows)
    {
        new Line[200],IDHolder,string[70];
        if(mysql_fetch_row(Line))
        {
            new ss = sscanf(Line,"p<|>dffffffffffffffddds[24]",IDHolder,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ],HouseInfo[h][PickupInsidePosX],HouseInfo[h][PickupInsidePosY],HouseInfo[h][PickupInsidePosZ],HouseInfo[h][SpawnOutsideX],HouseInfo[h][SpawnOutsideY],HouseInfo[h][SpawnOutsideZ],HouseInfo[h][SpawnOutsideAngle],
            HouseInfo[h][SpawnInsideX],HouseInfo[h][SpawnInsideY],HouseInfo[h][SpawnInsideZ],HouseInfo[h][SpawnInsideAngle],HouseInfo[h][InteriorID],HouseInfo[h][Locked],HouseInfo[h][Price],HouseInfo[h][Owner]);
            if(!ss)
            {
                if(!strcmp(HouseInfo[h][Owner],"NULL",true)) format(HouseInfo[h][Owner],MAX_PLAYER_NAME,"%s","\0");
                if(isnull(HouseInfo[h][Owner]))
                {
                    HouseInfo[h][PickupID] = CreateDynamicPickup(1273,23,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ]);
                    format(string,sizeof(string),"[House for sale]\r\n{FFFF00}Price: {FFFFFF}$%d",HouseInfo[h][Price]);
                }
                else
                {
                    HouseInfo[h][PickupID] = CreateDynamicPickup(1272,23,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ]);
                    format(string,sizeof(string),"[House NOT for sale]\r\n{FFFF00}Owner: {FFFFFF}%s",HouseInfo[h][Owner]);
                }
                HouseInfo[h][Label] = CreateDynamic3DTextLabel(string,COLOR_LIGHTGREEN,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ],20.0);
                GlobalInfo[HousesCreated] ++ ;
                printf("- HOUSE %d: X: %f || Y: %f || Z: %f",h,HouseInfo[h][PickupOutsidePosX],HouseInfo[h][PickupOutsidePosY],HouseInfo[h][PickupOutsidePosZ]);
            }
        }
    }
    return 1;
}
Anything wrong in this: Answers appreciated.

Jochem

Edit: I found out the problem if in mysql_fetch_row. I'd like to have an alternative to get the whole line! I do not want each single field apart
Reply
#2

Ew, ew, ew! Selecting individual rows is terribly slow and simply not done. You should select all rows at once and read out the data with a while-loop. Also if you enable the cache, then only the cache_* functions will work; the regular functions will not. You must disable the cache if you want to work with regular functions.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Ew, ew, ew! Selecting individual rows is terribly slow and simply not done. You should select all rows at once and read out the data with a while-loop. Also if you enable the cache, then only the cache_* functions will work; the regular functions will not. You must disable the cache if you want to work with regular functions.
Are the cache functions faster? Is there a fetch_row cache function? Could you show me how to read out all the data with a while loop (with my HouseInfo example)?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)