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

mysql_ping function crashes sometimes my server. :-$

Код:
	if(mysql_ping() ==-1)
	{
	    print("[MYSQL-DEAD] Reconnect");
	    mysql_reconnect();
	}
Reply

I'm doing in my script, save the data in the player database.
Makes a request of this kind in Public updateaccount:

Код:
new query[MAX_STRING];
format(query,sizeof(query)," UPDATE players SET PlayerLevel=%d,AdminLevel=%d,Sex=%d,Age=%d,Money=%d,Kills=%d,...,..., etc. a lot of data (over 35)  WHERE id=%d",
PlayerInfo[playerid][pLevel],
PlayerInfo[playerid][pAdmin],
PlayerInfo[playerid][pSex],
PlayerInfo[playerid][pAge],
PlayerInfo[playerid][pCash],
PlayerInfo[playerid][pKills],
....
etc. a lot of data (over 50)
....
PlayerInfo[playerid][pSQLID]);
mysql_query(query);
When I compile the mod, I get an error:
Код:
error 075: input line too long (after substitutions)
in line:
Код:
format(query,sizeof(query)," UPDATE players SET PlayerLevel=%d,AdminLevel=%d,Sex=%d,Age=%d,Money=%d,Kills=%d,...,..., etc. a lot of data (over 35)  WHERE id=%d",
How to make a long query?
That request to be as fast, optimized, does not create lag and did not create big server load and server mysql load.
Reply

Save the database to the variables that you use all the time. eg position, cash. etc. And such adminlvl save only when you change it, eg by a command.
Reply

Quote:
Originally Posted by PawnNewCommer
Посмотреть сообщение
I'm doing in my script, save the data in the player database.
Makes a request of this kind in Public updateaccount:

Код:
new query[MAX_STRING];
format(query,sizeof(query)," UPDATE players SET PlayerLevel=%d,AdminLevel=%d,Sex=%d,Age=%d,Money=%d,Kills=%d,...,..., etc. a lot of data (over 35)  WHERE id=%d",
PlayerInfo[playerid][pLevel],
PlayerInfo[playerid][pAdmin],
PlayerInfo[playerid][pSex],
PlayerInfo[playerid][pAge],
PlayerInfo[playerid][pCash],
PlayerInfo[playerid][pKills],
....
etc. a lot of data (over 50)
....
PlayerInfo[playerid][pSQLID]);
mysql_query(query);
When I compile the mod, I get an error:
Код:
error 075: input line too long (after substitutions)
in line:
Код:
format(query,sizeof(query)," UPDATE players SET PlayerLevel=%d,AdminLevel=%d,Sex=%d,Age=%d,Money=%d,Kills=%d,...,..., etc. a lot of data (over 35)  WHERE id=%d",
How to make a long query?
That request to be as fast, optimized, does not create lag and did not create big server load and server mysql load.
Use strcat
Reply

Quote:
Originally Posted by _[HuN]_Epsilon_
Посмотреть сообщение
mysql_ping function crashes sometimes my server. :-$

Код:
	if(mysql_ping() ==-1)
	{
	    print("[MYSQL-DEAD] Reconnect");
	    mysql_reconnect();
	}
Hi, our problems seem very similar (read my post on the previous page) It may be a problem with reconnecting instead of what I thought (reloading fs), hopefully this will be fixed, in the meantime, i'm using R5. does yours work in R5?
Reply

I changed to R6 plugin. It still says R5 plugin loaded when I run the server.
Is there wrong file compiled, or is it just forgotten to change that text in plugin?
Reply

Quote:
Originally Posted by Johnson_boy
Посмотреть сообщение
I changed to R6 plugin. It still says R5 plugin loaded when I run the server.
Is there wrong file compiled, or is it just forgotten to change that text in plugin?
....

Quote:
Originally Posted by xxmitsu
Посмотреть сообщение
If you compiled it from source, the version string isn't updated/changed with the string "R6" (if that annoys you, you can change that yourself).

But if you compare the source code with the previous version(R5), you'll see that there's a mutex implementation.
Код:
	while(true) {
		Mutex::getInstance()->_lockMutex();
And yes, It's just something that was forgot to be changed in the source code. The compiled binaries are just fine.
Reply

Quote:
Originally Posted by whitetigerswt
Посмотреть сообщение
Hi, our problems seem very similar (read my post on the previous page) It may be a problem with reconnecting instead of what I thought (reloading fs), hopefully this will be fixed, in the meantime, i'm using R5. does yours work in R5?
It crashes on both versions. (R5,R6)
Reply

where to put libmysqlclient.so.15

i have only ftp acces and start/stop server
Reply

something like.. onquerystart and mysql_is_result_stored?

pawn Код:
native mysql_is_stored_result( [connectionHandle = 1] );
forward OnQueryStart( query[], resultid, extraid, connectionHandle );
pawn Код:
public OnQueryStart(query[], resultid, extraid, connectionHandle)
{
    if(mysql_is_result_stored()) mysql_free_result();
    return 1;
}
Reply

where to put libmysqlclient.so.15

i have only ftp acces and start/stop server
Reply

The debian x86 version doesn't load on debian 5:

Failed (/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by plugins/mysql.so))

R5 x86 works fine, can someone recompile it please?
Reply

why i have this error:

Код:
[10:56:19]  Loading plugin: mysql.so
[10:56:19]   Failed (plugins/mysql.so: symbol _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_i, version GLIBCXX_3.4.9 not defined in file libstdc++.so.6 with link time reference)
R5 and why i can't load R6 i have error: cant load libmysqlclient_r.so.16
Reply

Getting this..??
Код:
[00:46:02]  

[00:46:02] ---------------------------

[00:46:02] MySQL Debugging activated (07/19/11)

[00:46:02] ---------------------------

[00:46:02]  

[00:46:02] >> mysql_connect( )

[00:46:02] CMySQLHandler::CMySQLHandler() - constructor called.

[00:46:02] CMySQLHandler::CMySQLHandler() - Connecting to "sql102.0fees.net" | DB: "fees0_8346974_jban" | Username: "fees0_8346974" ...

[00:46:23] CMySQLHandler::Connect() - Can't connect to MySQL server on 'sql102.0fees.net' (10060) (Error ID: 2003)

[00:46:23] >> mysql_ping( Connection handle: 1 )

[00:46:23] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[00:46:23] CMySQLHandler::~CMySQLHandler() - deconstructor called.

[00:46:23] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[00:46:23] CMySQLHandler::Disconnect() - You cannot call this function now. (Reason: Connection is dead)
Reply

so, now I need to use mysql_format instead of format when Im sending queries?
Reply

is this mysql_format faster than format?
Reply

Yay for mysql_format(), no point in declaring over 9000 strings with over 9000 cells for formatting queries.
Reply

Whats wrong here? I get tag mismatch on the mysql_format line:
pawn Код:
mysql_format(iQuery2, "INSERT INTO `playerbans` (`BannedName`, `BannedIP`, `Reason`, `Date`, `Admin`) VALUES ('%s', '%e', '%s', '%s', '%e')", "IP Ban", params, "No Reason Given", iStamp(), PNames[playerid]);

//format(iQuery2, sizeof(iQuery2), "INSERT INTO `playerbans` (`BannedName`, `BannedIP`, `Reason`, `Date`, `Admin`) VALUES ('%s', '%s', '%s', '%s', '%s')", "IP Ban", params, "No Reason Given", iStamp(), PNames[playerid]);

mysql_query(iQuery2);
Normal format works fine.
Reply

If I understand this correctly, mysql_format() does the escaping for you so there's no need to sanitize inputs before using them and formats the string all in one?
Reply

Quote:
Originally Posted by nemesis-
Посмотреть сообщение
If I understand this correctly, mysql_format() does the escaping for you so there's no need to sanitize inputs before using them and formats the string all in one?
Yes.
Reply


Forum Jump:


Users browsing this thread: 26 Guest(s)