[Plugin] [REL]SAMP-MySQL v0.15 - SAMP 0.3 supported!!! corrected version uploaded...
#1

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:
  • samp_mysql_next_field(): to access the next field when fetching data.
  • samp_mysql_affected_rows(): to get the number of affected rows by a query.
  • samp_mysql_debug(): to enable/disable debug mode.
  • samp_mysql_get_field_num(): to get the field value with its index => index 0 for the first field and so on.

[u]New Features:
  • SA:MP 0.3 supported
  • Memory deallocation: plugin is optimized to free memory correctly.

[u]Implemented functions:
  • samp_mysql_connect()
  • samp_mysql_select_db()
  • samp_mysql_query()
  • samp_mysql_store_result()
  • samp_mysql_fetch_row()
  • samp_mysql_get_field()
  • samp_mysql_num_rows()
  • samp_mysql_num_fields()
  • samp_mysql_strtok()
  • samp_mysql_ping()
  • samp_mysql_real_escape_string()
  • samp_mysql_free_result() => DON'T USE IT, IT WILL CRASH YOUR SERVER !!!
  • samp_mysql_close()
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...
Reply
#2

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

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

Shouldn't this topic be merged with this?
Reply
#5

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.
Reply
#6

Well, that's great!
Reply
#7

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.
Reply
#8

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

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

Cheers.

Reply
#10

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
}
Reply
#11

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?
Reply
#12

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");
}
Reply
#13

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
Reply
#14

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;
}
Reply
#15

Be careful...

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

No its not.

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

Works fine for me
Reply
#17

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...)
Reply
#18

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;
}
Reply
#19

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.
Reply
#20

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).
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)