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

What query would I send? SELECT *?
Reply

Quote:

[05:58:35] MySQL connection has been established
[05:58:35] mysql_stat(); Return "Uptime: 2056361 Threads: 1 Questions: 2289948 Slow queries: 0 Opens: 68895 Flush tables: 1 Open tables: 64 Queries per second avg: 1.114"
[05:59:12] mysql_ping(); Return: 1
[05:59:12] mysql_query("SELECT * FROM `wcf1_user` WHERE username = 'Dwayne_Johnson'",Resultid: 1);
[05:59:12] New thread created (Thread ID: -156173424 | Result ID: 1 | Threadsafe: No)

Must Threadsafe bei active to use that plugin?
On my homeserver I can login without any problems. On my rootserver i get that msg.
Reply

Can somebody help me please. Sureley someone is willing to help.
Reply

Quote:
Originally Posted by Mikep.
What query would I send? SELECT *?
What are you trying to do?
Reply

Alright, I have finally decided to release R3. It has been a long time since my last update, but now it's finally here. A lot of people helped to test this version, because it was a bit experimental. Anyway, I appreciate that a lot.

The new system might be a bit complicated to understand but in fact it is much better. (performance, CPU etc.)

You can basically connect to as much databases as you want. If you just use one connection, simply ignore the new parameter and compile your script with the latest includes. The best feature (which is now completely working) is by far the threading possibility. I highly suggest to use it if you have a lot of queries running and a high player base, otherwise you'll get lags and CPU problems on the server.

Код:
27/01/2010 (Updates & information):
- Plugin was rewritten from scratch (dynamic classes)
- It's the most stable version ever - the plugin tries to avoid crashes by ignoring invalid queries/requests
- Threading code works fine now! (Invalid queries will be skipped and not called in OnQueryFinish())
- The new parameter in all functions (except for mysql_connect()) allows you to connect to different databases. It has a default value, so you're not forced to use it
- You'll have to compile your script with the latest includes to get the plugin working
- Some new functions that might be useful
- Don't use mysql_connect() if the connection timed out .. simply use mysql_reconnect() (Host information is now saved until a restart)!
- I highly suggest to thread all queries (even UPDATE & INSERT queries)
Reply

where's 3rd debug mode for errors...
Reply

OMG. Along waited update.
Good news for me and others.. i think..
Thanks.
Reply

Very good! I waited for it long time ^^ Thanks!
Reply

Quote:
Originally Posted by $ЂЯĢ
Quote:
Originally Posted by Mikep.
What query would I send? SELECT *?
What are you trying to do?
I want to return the values Score, Cash and Level for a user.
Reply

Hello, how i can use mysql_reconnect now with R3? Im using a single mysql connect. Thanks.
Reply

It's not what you are doing in mySQL engine, it's pawn. IP is a string and not integer.

Код:
format(query2, 256, "SELECT INET_NTOA(ip) FROM table2 WHERE ip = '%s'", result);
Reply

Just because a column has a name 'ip' doesn't mean it is a string.
Here is an example value: 142487xxx
SELECT INET_NTOA(ip) FROM table2 = 80.x.x.x
http://dev.mysql.com/doc/refman/5.0/...tion_inet-ntoa
And actually "ip = '%s'", result);" this was the first thing that caused many problems.
For some reasons the script thinks that there are no more rows in table :/
Reply

I have got a really big problem. Some accounts in MySQL is 'broken'. Then one of them connect to my Linux server, the server shut downs, the logs writes just the last connect. The debuggins shows, select, store, and nothing then. There's no problem in my Windows server. People can connect without breaking the server. I dont know what's the problem. Im using R2 plugins.
Reply

I login to my database and i change values: Score: 2000 and Money: 1000 and when i login to server both of them changes to -1 so i get -1 money and -1 score. Here is my code, if somebody can help me or say what is wrong: http://pastebin.com/m3a15a556
Reply

Is it possible, that the "LIMIT" is bugged? I can't limit my querry command.
Look:

Код:
format(string,sizeof(string),"SELECT * FROM `"TABLENAME"` WHERE username = '%s' AND password = sha(concat(salt,sha(concat(salt,sha('%s'))))) LIMIT 11",pname,pass);
mysql_query(string);
Reply

Everything what you put in query is processed my mySQL server and has nothing to do with plugin.
Reply

Ok, but do you know, why the limit doesn't work?
Reply

I really love the whole queue idea. Great job, G-Stylezz. Again.

Besides that:
Код:
[14:22:20] CMySQLHandler::Connect() - Connection was successful.
[14:22:20] >> mysql_query( Connection handle: 1 )
[14:22:20] CMySQLHandler::Query(select * from hrp_door) - Successfully executed.
[14:22:20] >> mysql_query( Connection handle: 1 )
[14:22:20] CMySQLHandler::Query(select * from hrp_gz) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[14:22:20] >> mysql_query( Connection handle: 1 )
[14:22:20] CMySQLHandler::Query(select * from hrp_anim) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[14:22:20] >> mysql_query( Connection handle: 1 )
You do such a little, confusing thing in here:
Код:
cell AMX_NATIVE_CALL NativeFunctions::n_mysql_query( AMX* amx, cell* params )
{
	unsigned int cID = params[3]-1;
	MySQL_Log(">> mysql_query( Connection handle: %d )",cID+1);
	VALID_CONNECTION_HANDLE("mysql_query",cID);
	CMySQLHandler *cHandle = SQLHandle[cID];
	cHandle->Query(AMX_H->GetString(amx,params[1]),params[2]);
	return 0;
}
Returning 0 I mean. In my plugin-cross-compatible code I just use (and used, even with the old version of your plugin) if(mysql_query()) to check whether I should process the query futher. You disallow the code to work by returning 0 whatever the result is - it's also incomatible with the older version. I also can't define a macro to check whether its equal to 0, as mysql_query() is not only used with if() (like in threaded queries), so the code would be quite crappy.
I think you could simply return 0/1 with non-threaded queries, and -1 in threaded ones. The code would be backward compatible then.

It is made on purpose, or it's rather an omission, like:
Quote:

my_ulonglong CMySQLHandler::InsertId()
{
if(!m_bIsConnected) {
NativeFunctions::MySQL_Log("CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead).");

?
Regards!


EDIT:
Another catch.
Код:
cell AMX_NATIVE_CALL NativeFunctions::n_mysql_fetch_field( AMX* amx, cell* params )
{
	/*MySQL.field = (MYm_stField *)malloc(100);
	MySQL.field = mysql_fetch_field_direct(MySQL.res, params[1]);
	AmxStringHandler->SetString(amx,params[2],std::string(MySQL.field->name));
	MySQL_Log("mysql_fetch_field(Number: %d); Return: \"%s\"",params[1],MySQL.field->name);
	free(MySQL.field);*/
	return 1;
}
You register the native which is never used.
Reply

Can't find the mysql.so?
Reply

Quote:
Originally Posted by Wicko
I really love the whole queue idea. Great job, G-Stylezz. Again.

Besides that:
Код:
[14:22:20] CMySQLHandler::Connect() - Connection was successful.
[14:22:20] >> mysql_query( Connection handle: 1 )
[14:22:20] CMySQLHandler::Query(select * from hrp_door) - Successfully executed.
[14:22:20] >> mysql_query( Connection handle: 1 )
[14:22:20] CMySQLHandler::Query(select * from hrp_gz) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[14:22:20] >> mysql_query( Connection handle: 1 )
[14:22:20] CMySQLHandler::Query(select * from hrp_anim) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[14:22:20] >> mysql_query( Connection handle: 1 )
First of all, thanks for your input. You get this error, because you didn't free or store your result anywhere.

Quote:
Originally Posted by mysql.com
If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order.

This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between.
The plugin doesn't free and/or store results anywhere, so you'll have to do it manually by calling the functions. (mysql_store_result() & mysql_free_result())

Quote:
Originally Posted by Wicko
You do such a little, confusing thing in here:
Код:
cell AMX_NATIVE_CALL NativeFunctions::n_mysql_query( AMX* amx, cell* params )
{
	unsigned int cID = params[3]-1;
	MySQL_Log(">> mysql_query( Connection handle: %d )",cID+1);
	VALID_CONNECTION_HANDLE("mysql_query",cID);
	CMySQLHandler *cHandle = SQLHandle[cID];
	cHandle->Query(AMX_H->GetString(amx,params[1]),params[2]);
	return 0;
}
Returning 0 I mean. In my plugin-cross-compatible code I just use (and used, even with the old version of your plugin) if(mysql_query()) to check whether I should process the query futher. You disallow the code to work by returning 0 whatever the result is - it's also incomatible with the older version. I also can't define a macro to check whether its equal to 0, as mysql_query() is not only used with if() (like in threaded queries), so the code would be quite crappy.
I think you could simply return 0/1 with non-threaded queries, and -1 in threaded ones. The code would be backward compatible then.
To be honest, I didn't really care about the return value because I was busy with the whole threading code. Anyway, this is fixed in the latest binary and I'm going to release it later today.

Quote:
Originally Posted by Wicko
It is made on purpose, or it's rather an omission, like:
Quote:

my_ulonglong CMySQLHandler::InsertId()
{
if(!m_bIsConnected) {
NativeFunctions::MySQL_Log("CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead).");

?
Regards!
No, this was obviously not made on purpose. It was rather a copy & paste message, which I forgot to edit before releasing.

Quote:
Originally Posted by Wicko
EDIT:
Another catch.
Код:
cell AMX_NATIVE_CALL NativeFunctions::n_mysql_fetch_field( AMX* amx, cell* params )
{
	/*MySQL.field = (MYm_stField *)malloc(100);
	MySQL.field = mysql_fetch_field_direct(MySQL.res, params[1]);
	AmxStringHandler->SetString(amx,params[2],std::string(MySQL.field->name));
	MySQL_Log("mysql_fetch_field(Number: %d); Return: \"%s\"",params[1],MySQL.field->name);
	free(MySQL.field);*/
	return 1;
}
You register the native which is never used.
I forgot about this function, but it's finished in the coming version today. Besides your input, I must admit that there was a bug with passing the correct connection handle to the callback which has been fixed now. Webflori figured this out, so thanks to him too.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)