Differences on "SELECT", and If that's is the single fast way. -MYSQL.
#1

Hello.

Question 1:
I want to ask you if there's fast another way for this script code:
pawn Code:
if(!strcmp(cmd, "/find", true))
{
    new Float:VPos[3];
    cmd = strtok(cmdtext, idx);


    format(query, sizeof(query), "SELECT `Spawn` FROM `cars` WHERE `CarID`='%d' AND `Owner`='%s'", strval(cmd), Name(playerid));
    mysql_query(query);
    mysql_store_result();
    new values = mysql_fetch_int();
    if(values != -1)
    {
        GetVehiclePos(values, VPos[0], VPos[1], VPos[2]);
        SetPlayerCheckpoint(playerid, VPos[0], VPos[1], VPos[2], 2);
    }
    else SendClientMessage(playerid, White, "You're vehicle isn't spawned yet.");
    mysql_free_result();
    return true;
}
Question 2:
What are the diffrences on "SELECT" in this ways, and how can I use the results of the way: "SELECT `Key1`, `Key2`..."

Way 1:
pawn Code:
format(query, sizeof(query), "SELECT `Key1`, `Key2` FROM `folder` WHERE `User`='%s'", GetName(playerid));
Way 2:
pawn Code:
format(query, sizeof(query), "SELECT * FROM `users` WHERE `User`='%s'", GetName(playerid));
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
    mysql_fetch_field_row(loadstr[0], "Key1");
    mysql_fetch_field_row(loadstr[1], "Key2");
    mysql_fetch_field_row(loadstr[2], "Key3");
    PlayerSystem[playerid][Key1] = strval(loadstr[1]);
    PlayerSystem[playerid][Key2] = strval(loadstr[2]);
    PlayerSystem[playerid][Key3] = strval(loadstr[3]);
}
mysql_free_result();
What is better and how can I use the way 1? how can I take the results of Key1, Key2.


Thanks.
Reply
#2

I understood from some thread in the Discussion forum that Way 1 is better,
Well how can I check the results of Key1 and Key2 into variables?
Reply
#3

UP... Please help me with question 2.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)