[Plugin] [REL] MySQL Plugin (Now on github!)

Oh my god. Start learning MySQL from begining. This isn't dini.
Reply

pawn Code:
WHERE (`id` = '%s')
This is shit! The reg id isn't string, use this:
pawn Code:
WHERE (`id` = '%d')
Queryes: ( Example )
pawn Code:
format(query, sizeof(query), "UPDATE `players` SET `PlayerLevel`='%d', `AdminLevel`='%d', `DonateRank`='%d' WHERE `id` = '%d'", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pDonateRank], PlayerInfo[playerid][pSQLID]);
mysql_query(query);

// If query is long, continue this
format(query, sizeof(query), "UPDATE `players` SET `UpgradePoints`='%d', `ConnectedTime`='%d' WHERE `id` = '%d'",PlayerInfo[playerid][gPupgrade], PlayerInfo[playerid][pConnectTime], PlayerInfo[playerid][pSQLID]);
mysql_query(query);
Reply

Code:
UPDATE players SET PlayerLevel=%d, AdminLevel=%d, DonateRank=%d WHERE id=%d
This would do the job. Without useless tags to shorten the string.
Reply

Hello community,

I have found some error...

In the orginal thread G-sTyLeZzZ write:

Quote:

# mysql_ping( [connectionHandle = 1] )
* Returns true (1) if the connection is alive, else (-1)

...but in the wiki he writes:

Quote:

0 if alive, 1 if dead.

if(!mysql_ping()) print("MySQL connection is still alive!");
if(mysql_ping()) print("MySQL connection is dead!");

So my question, which of them two is now the RIGHT usage?

Is "mysql_ping()" 1 = alive or 1 = dead??

Greetings - Fake
Reply

0 if alive, 1 if dead. You can always try it yourself, can't you?
Reply

Hello guys,

I have found a very big bug!
The usage "mysql_ping()" is still write false in the wiki...

I tested it and found the following...

Code:
if(mysql_ping())
{
   CONNECTION is true
}
But...

Code:
if(!mysql_ping())
{
   CONNECTION is false
}
That means, the function "if(mysql_ping())" returns 1 - ALIVE and 0 - DEATH.


On the other side it's not logical for MySQL to return " !mysql_ping() " as true, because ! means false...
Thats the right return and I tested it again and again, thats okay!

So for alle the guys who has problems, fix this and don't do it like the wiki!


Greetings - 4#Future
Reply

Quote:
Originally Posted by 4#Future
View Post
big wall of text
OH MY GOD THIS IS BIGGER THAN Y2K! WE'RE ALL GOING TO DIE







f
Reply

Quote:
Originally Posted by 4#Future
View Post
On the other side it's not logical for MySQL to return " !mysql_ping() " as true, because ! means false...
Yes it is logical: http://dev.mysql.com/doc/refman/5.1/en/mysql-ping.html
Quote:

Return Values

Zero if the connection to the server is active. Nonzero if an error occurred. A nonzero return does not indicate whether the MySQL server itself is down; the connection might be broken for other reasons such as network problems.

Return values of this plugin has been changed many times already.
Reply

Quote:
Originally Posted by GangsTa[MD]
Посмотреть сообщение
Where can I learn to script in MySQL?
Wiki page https://sampwiki.blast.hk/wiki/MySQL_Plugin

some tutorials here http://www.w3schools.com/sql/default.asp
Reply

Quote:
Originally Posted by Hal
Посмотреть сообщение
It's https://sampwiki.blast.hk/wiki/MySQL
Reply

Quote:
Originally Posted by [NoV]LaZ
Посмотреть сообщение
I don't know if anyone has this issue, but loading vehicles, checkpoints, etc. via database in OnGameModeInit using threaded queries is not possible. Or, maybe it is possible, I just don't know how.
I solved this. My problem was with the table. I attributed the wrong data type to fields holding float values. The vehicles are created although in server console is printed "Number of vehicles loaded: 0".
Reply

@LaZ:
The reason it says 0 models in the console is because that info is printed right after OnGameModeInit; however, when using a threaded query the code gets executed slightly after OnGameModeInit.
In my opinion it's not really neccessary to use threaded queries in OnGameModeInit unless using an external server or something.
Reply

I get this error each time i try to use this plugin on windows :

What should i do ?
Reply

Does it work on linux?
If not. do you have

pawn Код:
main() { }
in your script?
Reply

Quote:
Originally Posted by Souvlaki
Посмотреть сообщение
Does it work on linux?
If not. do you have

pawn Код:
main() { }
in your script?
I didn't have it, now i added it and works perfect, thanks !
Reply

mmmm
Reply

Here is all you need: https://sampwiki.blast.hk/wiki/MySQL
Reply

k thx ....
Reply

Field names can't include spaces, so I can't give you example using your code. And don't post me a visitor message asking for a help ever again.
Reply

For me everytime crash server with this in windows. Usally after escaped text in query ( Chatlog, Commandlog ).

In linux not have any problem.
Reply


Forum Jump:


Users browsing this thread: 15 Guest(s)