SA-MP Forums Archive
[Plugin] [REL]SAMP-MySQL v0.15 - SAMP 0.3 supported!!! corrected version uploaded... - 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]SAMP-MySQL v0.15 - SAMP 0.3 supported!!! corrected version uploaded... (/showthread.php?tid=7106)

Pages: 1 2 3 4 5 6


[REL]SAMP-MySQL v0.15 - SAMP 0.3 supported!!! corrected version uploaded... - ADreNaLiNe-DJ - 16.07.2007

First of all, i just wanna precise some things about MySQL, licenses and this plugin:
- MySQL allows developpers to dev and distribute application freely using their API only if: it not includes the database engine and it's just a connector to the database.
- If you want to dev something like this, you must ask authorization and make your plugin opensource.
- In my case, i have a writen autorization of MySQL to distribute a plugin for SAMP.
- The following plugin is free to use.
- You are free to use it in your gamemodes, filterscripts or plugins.


Official Plugin Page is here


SAMP-MySQL v0.15 PAWN KIT includes PAWN .inc file (to be placed in "include" dir in pawno dir) and .pwn example file.
File size: 1.55kb
Download links:


SAMP-MySQL v0.15 Windows includes sourcecode, .dll file (windows plugin) ans libmysql.dll (place in the folder of the executable of samp server.
File size: 514kb
Download links: SAMP-MySQL v0.15 Ubuntu includes Linux .so file, libmysqlclient.so for Ubuntu and source.
File size: 895 kb
Download links: SAMP-MySQL v0.15 CentOS includes Linux .so file, libmysqlclient.so for CentOS and source.
File size: 895 kb
Download links: [u]Future Development:
[u]New Features:
[u]Implemented functions: If you have some other questions about this plugins, you'll find my email on this page.

All your suggestions, about new features or getting better this project, are very pleased...


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 16.07.2007

If you don't need development packages, just download "Lite" version...


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 16.07.2007

here's the mirror for lite version: http://rapidshare.com/files/43254193...-lite.zip.html


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - d.wine - 16.07.2007

Shouldn't this topic be merged with this?


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 16.07.2007

Quote:
Originally Posted by d.wine
Shouldn't this topic be merged with this?
Nop, it's a new version and old topic was "pollued" with licensing questions.


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - d.wine - 16.07.2007

Well, that's great!


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - Mike - 16.07.2007

Could you swing by IRC sometime? (irc://irc.gtanet.com/sa-mp.plugins)
It'd benefit everyone if you hosted this on dev.sa-mp.com, i'm generally around from 3pm onwards (GMT) and can set it up for you.


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 16.07.2007

Ok no problem, i'll try to remember that, for tomorrow...


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - Matite - 17.07.2007

Wow... this is going to be very handy indeed.

Cheers.




Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - boylett - 17.07.2007

This is great but I have a suggestion. When reading multiple rows, why not return 1 if youve read a row and 0 otherwise, like fread. Then we could use:

pawn Code:
while(samp_mysql_fetch_row(string))
{
  // code
}



Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - courage - 17.07.2007

i have a question, in your example you showed this:
new resultline[1024];
print("%s", resultline);

As we all know that we can do this in PHP:
$query = mysql_connect("localhost", "user", "i_dont_have_a_password");
if(!$query) { echo "fail"; }

but what about Pawn?
new query[1024];
query = samp_mysql_connect("localhost", "user", "i_dont_have_a_password");
if(!query) { print("fail"); }

Right?


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 17.07.2007

Quote:
Originally Posted by courage
i have a question, in your example you showed this:
new resultline[1024];
print("%s", resultline);

As we all know that we can do this in PHP:
$query = mysql_connect("localhost", "user", "i_dont_have_a_password");
if(!$query) { echo "fail"; }

but what about Pawn?
new query[1024];
query = samp_mysql_connect("localhost", "user", "i_dont_have_a_password");
if(!query) { print("fail"); }

Right?
First of all, your PHP sample code is wrong...

PHP code:
Code:
$connection_identifier=mysql_connect(..); //it's the connection identifier to be returned not a query !
if(!connection_identifier)
{
 echo "failure...."; 
}
In my plugin, i've made returns values as in the C-API of mysql => when a function returns 0 it's a success, else it's a failure....
Code:
new connection_identifier;
connection_identifier=samp_mysql_connect(...);
if(connection_identifier==1)
{
 printf("failure");
}



Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 17.07.2007

Quote:
Originally Posted by [NB
Boylett ]
This is great but I have a suggestion. When reading multiple rows, why not return 1 if youve read a row and 0 otherwise, like fread. Then we could use:

pawn Code:
while(samp_mysql_fetch_row(string))
{
  // code
}
If you took the time to read the documentation, you'll see that feature is already available => http://lostgangwarz.free.fr/samp_mys...ysql_fetch_row


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - boylett - 17.07.2007

Quote:
Originally Posted by [RAZ
ADreNaLiNe-DJ ]
Quote:
Originally Posted by [NB
Boylett ]
This is great but I have a suggestion. When reading multiple rows, why not return 1 if youve read a row and 0 otherwise, like fread. Then we could use:

pawn Code:
while(samp_mysql_fetch_row(string))
{
  // code
}
If you took the time to read the documentation, you'll see that feature is already available => http://lostgangwarz.free.fr/samp_mys...ysql_fetch_row
thanks, i didnt see the documentation :P

anyway, heres a little function I made to add slashs to characters in a string

So AddSlashs("i ' abc ' lol'",'\'') would return i \' abc \' lol\'

this is to stop mysql errors when putting a player entered strings into a mysql query

pawn Code:
AddSlashs(s[],c)
{
    new string[STR];
    for(new i = 0, j = strlen(s); i < j; i++)
    {
      if(s[i] == c)
      {
        string[i] = '\\';
            i++;
            string[i] = c;
        j++;
      } else string[i] = s[i];
    }
    return string;
}



Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 17.07.2007

Be careful...

Escaping characters in SQL Syntax is with an ' not slashes !!


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - boylett - 17.07.2007

No its not.

SELECT `pass` FROM `users` WHERE `name` = 'Some\'Username'

Works fine for me


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 17.07.2007

Quote:
Originally Posted by [NB
Boylett ]
No its not.

SELECT `pass` FROM `users` WHERE `name` = 'Some\'Username'

Works fine for me
Well...
I'll verify this thing...
At work (an at home), i must escape simple quotes in SQL queries with a simple quote...
I'll verify, if it's a specificity if SQL Server (it's that sh** i'm using at work...)


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - boylett - 17.07.2007

Well, a simple modeification to the function makes it work for everything:

pawn Code:
AddSlashs(s[],c,escapechar)
{
    new string[STR];
    for(new i = 0, j = strlen(s); i < j; i++)
    {
      if(s[i] == c)
      {
        string[i] = escapechar;
            i++;
            string[i] = c;
        j++;
      } else string[i] = s[i];
    }
    return string;
}



Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - fluid - 17.07.2007

i was working on a new "stunt" script last night, and thinking about how great it would be if i could store some of the crap thats hogging up real-estate in my script in a mysql table...or a bunch of them, whatever the case may be. lol...then i get on here today, and see this thread.

now i get to rework about 4 hours of scripting

i am glad that i found this early in my development lol...and i definitely love and appreciate the plugin. have not tried to get it working yet, thats next, but i dont think ill have any problems compiling it on a debian server.


Re: [REL] SAMP-MySQL and SAMP-MYSQL-lite v0.11 (last edit 07-16-2007) - ADreNaLiNe-DJ - 17.07.2007

I think it will be not to hard...

I've compile the .so file on Ubuntu 6.06 (debian based)

If you have some troubles with compiling, try to install all packages you can find about MySQL... (using apt-get).