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

Код:
git clone --recursive https://github.com/pBlueG/SA-MP-MySQL.gi...5725023git checkout tags/R39-3
git submodule update
cd boost_1_57_0/
sudo bash bootstrap.sh --prefix=/usr/local --with-libraries=system,chrono,thread,date_time,atomic,filesystem
sudo ./b2 variant=release link=static threading=multi address-model=32 runtime-link=shared -j2 -d0 install
cd ..
sudo ldconfig
make
These are the commands to compile R39-3 on Linux (implying you downloaded the boost 1.57 source and unzipped it into the folder "boost_1_57_0").

To compile the master branch, those commands stay mostly the same. Just remove the second and third command ("git checkout" and "git submodule") and execute these before "make":
Код:
mkdir build
cd build
cmake ..
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
Код:
git clone --recursive https://github.com/pBlueG/SA-MP-MySQL.gi...4110713git checkout tags/R39-3
git submodule update
cd boost_1_57_0/
sudo bash bootstrap.sh --prefix=/usr/local --with-libraries=system,chrono,thread,date_time,atomic,filesystem
sudo ./b2 variant=release link=static threading=multi address-model=32 runtime-link=shared -j2 -d0 install
cd ..
sudo ldconfig
make
These are the commands to compile R39-3 on Linux (implying you downloaded the boost 1.57 source and unzipped it into the folder "boost_1_57_0").

To compile the master branch, those commands stay mostly the same. Just remove the second and third command ("git checkout" and "git submodule") and execute these before "make":
Код:
mkdir build
cd build
cmake ..
I actually got very far with that, however I am still getting an error:
Код:
Compiling plugin..
Compiling plugin SDK..
Linking (dynamic)..
Linking (static)..
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [static_link] Error 1
When using this command "ldconfig -p | grep mysql" I am getting this as an output:
Код:
        libmysqlclient_r.so.16 (libc6) => /usr/lib/mysql/libmysqlclient_r.so.16
        libmysqlclient_r.so (libc6) => /usr/lib/mysql/libmysqlclient_r.so
        libmysqlclient_r.so (libc6) => /usr/lib/libmysqlclient_r.so
        libmysqlclient.so.16 (libc6) => /usr/lib/mysql/libmysqlclient.so.16
        libmysqlclient.so (libc6) => /usr/lib/mysql/libmysqlclient.so
Reply

That means that there is no static MySQL client library to link with the static MySQL plugin. This is normal on CentOS though, thus you can and should only compile and use the standard (dynamic) MySQL plugin. You can compile it directly by calling "make dynamic".
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
That means that there is no static MySQL client library to link with the static MySQL plugin. This is normal on CentOS though, thus you can and should only compile and use the standard (dynamic) MySQL plugin. You can compile it directly by calling "make dynamic".
I can compile it dynamically, but I'm using MySQL 5.5.44 because of certain dependencies that require a specific version or higher and I can't downgrade. So I am getting this error: Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)

So I have to use a static MySQL plugin.
Reply

Quote:
Originally Posted by Jeroen52
Посмотреть сообщение
I can compile it dynamically, but I'm using MySQL 5.5.44 because of certain dependencies that require a specific version or higher and I can't downgrade. So I am getting this error: Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)

So I have to use a static MySQL plugin.
Dont know about CentOS but on ubuntu i would try

Try installing libmysqlclient or libmysqlclient-dev (Second one will work for sure but i always try to avoid dev versions on live servers)
Reply

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Hi, im still having problems with this; It is not working as its meant to be as it should: Remove the row having the same "id" in "table2" as when the "id" in "table1" is deleted.


Can anyone send me the cascade statement so that it could do the above correctly please?
Reply

Quote:
Originally Posted by vannesenn
Посмотреть сообщение
Who? I didn't work in Visual Studio.
If you want to build for your Linux distro, you gotta build it on Linux.
If you want to build it for Windows, you gotta build it on Windows.
Reply

Ah, then ok
Reply

Which function to use?
mysql_query, mysql_tquery or mysql_pquery?
Reply

Quote:
Originally Posted by vannesenn
Посмотреть сообщение
Which function to use?
mysql_query, mysql_tquery or mysql_pquery?
Well it depends on what do you want to achieve. mysql_query is used for unthreaded queries, mysql_tquery for threaded and mysql_pquery for parallel queries.
Reply

I decided for mysql_tquery but I don't know then how to count rows from cache. Before mysql_tquery I use mysql_query and for counting cache_get_row_count but now I don't see any way how count rows with mysql_tquery and without calling a public. Eg.

Code:
stock _HRP_PreviewAccountCheck(_name[])
{
	new dbQUERY[86];
	new Cache:_Result;

	mysql_format(_HRP_server_database, dbQUERY, 86, "SELECT ID FROM "_USER_DB" WHERE Ime = '%e' LIMIT 0, 1", _name);
	_Result = mysql_tquery(_HRP_server_database, dbQUERY, true);

	if(cache_get_row_count()) // UKOLIKO POSTOJI RAČUN
	{
		cache_delete(_Result);
		return (true);
	}

	cache_delete(_Result);
	return (false);
}
I hope you understand me. Forget for true(3th params in mysql_tquery). I just changed on mysql_tquery from mysql_query
Reply

If you want to use mysql_tquery(send a threaded query) you will have to provide a callback(public function). It can be an inline(y_inline) function but at the end, its the same.


To use it like your example, you would need to use mysql_query. It is the only one that returns a result refference.
Reply

And can I mix mysql_query and mysql_tquery?
Reply

Ofcourse! You can use whichever is needed for the query.
Reply

Thanks a lot
Reply

Code:
[15:37:41] [debug] Server crashed while executing bcrpg_main.amx
[15:37:41] [debug] AMX backtrace:
[15:37:41] [debug] #0 native mysql_close () from mysql.dll
[15:37:41] [debug] #1 0007d0e8 in ?? (... <1073741823 arguments>) at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty\gamemodes\bcrpg_main.pwn:69
[15:37:41] [debug] #2 00015ce0 in public ScriptInit_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty\pawno\include\YSI\..\YSI_Coding\..\YSI_Data\..\YSI_Coding\..\YSI_Internal\y_cgen.inc:30
[15:37:41] [debug] #3 0000b7b4 in public FIXES_OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty\pawno\include\YSI\..\YSI_Coding\..\YSI_Internal\..\YSI_Server\y_scriptinit.inc:213
[15:37:41] [debug] #4 00004304 in public OnGameModeExit () at C:\Documents and Settings\Administrator\Desktop\misc\boneCounty\pawno\include\fixes.inc:3419
[15:37:41] [debug] Native backtrace:
[15:37:41] [debug] #0 72632074 in ?? () from samp-server.exe
[15:37:41] [debug] #1 010979d4 in ?? () from LIBMYSQL.dll
I got my mode split into several files. I started getting this error after I started to save server stats when the server closes:

main file OnGameModeExit (bcrpg_main, line 69, as shown in the error):

pawn Code:
public OnGameModeExit ()
{
    mysql_close (mysqlHandle);
    FadeExit ();

    return (true);
}
statistics.pwn OnGameModeExit (not shown in the error output, but I'm sure this is causing the error)

pawn Code:
Hook:stats_OnGameModeExit()
    SaveServerStatistics ();

Although the log file shows that everything is fine?

Code:
15:54:18	CMySQLConnection::Disconnect	OK	connection was closed
15:54:18	CMySQLConnection::Disconnect	OK	connection was closed
Reply

Try re-downloading R39-3 (and don't forget to replace the libmysql.dll).
Do you have the parameter pool_size in mysql_connect set to zero?
Reply

The problem is that I can't use newer version than R34, as right now I'm using Windows XP, which doesn't support KERNEL32 library.

EDIT: pool_size was added in R35, so I can't even use it. :\
Reply

Actually, the old function of fetching both field(column) and row is done by mysql_fetch_field_row ? which retrives both fiekd and row, but in new plugin which equivalent cmd would do so?

My code
Code:
if(cache_num_rows(mysql) > 0)
   	{
	    //while(mysql_fetch_field_row(string,"|"))
            cache_get_row(10,"|",string);// argument type mismatch, i know the param entered is wrong!
	    {
	        sscanf(string,"p<|>s[7]i",Clan,score);
	        format(content,sizeof(content),"%s%s\t\t%d Score\n",content,Clan,score);
            }
	}
Reply

It doesn't work like that at all. Every field is already fetched separately and you don't have to split it yourself. You can get the value either by the position in the result or by column name, which is slightly slower.
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)