14.06.2011, 20:55
I'm only just learning how to do MySQL, so I'm making a few mistakes.
I've converted my accounts system from SQLite to MySQL, or am attempting to. In the wiki page on the mysql plugin it says that mysql_query returns 1 if successful and 0 if unsuccessful.
I made some defines for multi threading, and when I perform a query, it returns the value of the define rather than returning 1 or 0.
Here is a small piece of the code.
and under OnQueryFinish i have
Ok, the problem is the query is returning the value of the thread define (39) when its supposed to return 1 or 0. What have i done wrong?
I've converted my accounts system from SQLite to MySQL, or am attempting to. In the wiki page on the mysql plugin it says that mysql_query returns 1 if successful and 0 if unsuccessful.
I made some defines for multi threading, and when I perform a query, it returns the value of the define rather than returning 1 or 0.
Here is a small piece of the code.
pawn Код:
#define THREAD_CHECKGANG 39
pawn Код:
new query[256];
format(query, sizeof(query), "SELECT `GangName` FROM `Gangs` WHERE `GangName`='%s'", gangname);
if(mysql_query(query, THREAD_CHECKGANG) == 1)
return -1;//gang already exists
else
{
//Create Gang Here
}
}
pawn Код:
case THREAD_CHECKGANG:
{
mysql_store_result();
if(mysql_num_rows() > 0)
{
mysql_free_result();
return true;
}
else
{
mysql_free_result();
return false;
}
}