SA-MP Forums Archive
[Plugin] [REL] MySQL Plugin (Now on github!) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] [REL] MySQL Plugin (Now on github!) (/showthread.php?tid=56564)



Re: [REL] MySQL Plugin (Now on github!) - maddinat0r - 25.06.2015

Код:
git clone --recursive https://github.com/pBlueG/SA-MP-MySQL.git
git 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 ..



Re: [REL] MySQL Plugin (Now on github!) - Jeroen52 - 25.06.2015

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
Код:
git clone --recursive https://github.com/pBlueG/SA-MP-MySQL.git
git 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



Re: [REL] MySQL Plugin (Now on github!) - maddinat0r - 25.06.2015

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".


Re: [REL] MySQL Plugin (Now on github!) - Jeroen52 - 25.06.2015

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.


Re: [REL] MySQL Plugin (Now on github!) - DRIFT_HUNTER - 25.06.2015

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)


Re: [REL] MySQL Plugin (Now on github!) - Evocator - 26.06.2015

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?


Re: [REL] MySQL Plugin (Now on github!) - Jeroen52 - 04.07.2015

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.


Re: [REL] MySQL Plugin (Now on github!) - vannesenn - 04.07.2015

Ah, then ok


Re: [REL] MySQL Plugin (Now on github!) - vannesenn - 04.07.2015

Which function to use?
mysql_query, mysql_tquery or mysql_pquery?


Re: [REL] MySQL Plugin (Now on github!) - dusk - 04.07.2015

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.


Re: [REL] MySQL Plugin (Now on github!) - vannesenn - 04.07.2015

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


Re: [REL] MySQL Plugin (Now on github!) - dusk - 04.07.2015

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.


Re: [REL] MySQL Plugin (Now on github!) - vannesenn - 04.07.2015

And can I mix mysql_query and mysql_tquery?


Re: [REL] MySQL Plugin (Now on github!) - dusk - 04.07.2015

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


Re: [REL] MySQL Plugin (Now on github!) - vannesenn - 04.07.2015

Thanks a lot


Re: [REL] MySQL Plugin (Now on github!) - b3nz - 07.07.2015

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



Re: [REL] MySQL Plugin (Now on github!) - maddinat0r - 07.07.2015

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?


Re: [REL] MySQL Plugin (Now on github!) - b3nz - 07.07.2015

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. :\


Re: [REL] MySQL Plugin (Now on github!) - DetoNater - 08.07.2015

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);
            }
	}



Re: [REL] MySQL Plugin (Now on github!) - Vince - 08.07.2015

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.