AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with MySQL (https://forums.alliedmods.net/showthread.php?t=270823)

andrzN 08-30-2015 08:37

Help with MySQL
 
Hey guys!

I need some help, I have a rank system which is connected to a mysql database.
The thing I need help with, is to reset certain coulumns in the mysql table.

Lets say for example I have these tables: kills, deaths, rounds. And I want to set the "kills" and "deaths" for everyone who is stored in the database to 0.

How can I do this through a plugin?

I tried these:

PHP Code:

SQL_ThreadQuery(g_sql_tuple"qh_IgnoreHandle""UPDATE `rank_system` SET `kills=NULL`,`deaths=NULL`;"); 

PHP Code:

SQL_ThreadQuery(g_sql_tuple"qh_IgnoreHandle""EMPTY FROM `rank_system` WHERE `kills=NULL`,`deaths=NULL`;"); 

PHP Code:

SQL_ThreadQuery(g_sql_tuple"qh_IgnoreHandle""DELETE FROM `rank_system` WHERE `kills=NULL`,`deaths=NULL`;"); 

But it doesnt affect any of the players' score.

I really appreciate some help!

Phant 08-30-2015 11:37

Re: Help with MySQL
 
Why not TRUNCATE TABLE?

wickedd 08-30-2015 12:41

Re: Help with MySQL
 
PHP Code:

SQL_ThreadQuery(g_sql_tuple"qh_IgnoreHandle""UPDATE `rank_system` SET `kills=NULL`,`deaths=NULL`;"); 

:arrow:

PHP Code:

SQL_ThreadQuery(g_sql_tuple"qh_IgnoreHandle""UPDATE `rank_system` SET `kills` = 0,`deaths` = 0;"); 


Bugsy 08-30-2015 12:59

Re: Help with MySQL
 
You are enclosing the field AND value in quotes, you should only enclose the field; it should be 'Field'=NULL, not 'Field=NULL'. Quotes aren't really needed at all, unless there are spaces in the field, but that's not a good naming practice to begin with.

Code:

UPDATE `rank_system` SET `kills=NULL`,`deaths=NULL`;");
:arrow:
Code:

UPDATE `rank_system` SET `kills'=NULL,`deaths'=NULL;");


All times are GMT -4. The time now is 22:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.