Nume: SiNiSTER
Tip: Pawn
Informatii: -
Descarcare:

17/07/2011:
- mysql_format() a fost adaugata)
09/07/2011:
- buguri legate de query rezolvate
Cum il instalezi:
Windows: Copiaza mysql.dll in folderul /plugins si libmysql.dll folderul serverului tau. Apoi adauga in server.cfg 'plugins mysql'
Linux: Copiaza mysql.so in folderul /plugins si adauga in server.cfg 'plugins mysql.so'
PAWN Scripting: (a_mysql.inc)
Functii Native: (Toti parametrii din parantezele patrate sunt optionalel)
mysql_affected_rows( [connectionHandle = 1] )
mysql_close( [connectionHandle = 1] )
Asigura-te ca "chemi" acesta in OnGameModeExit()/OnFilterscriptExit()[*]mysql_connect( const host[], const user[], const database[], const password[] )
Returns a connection handle you can use for multiple connections

//acest exemplu demonstreaza cum sa folosesti mai multe conexiuni
new SQLPtr[2]; //global var
...
Function()
{
SQLPtr[0] = mysql_connect(...);
SQLPtr[1] = mysql_connect(...);
mysql_query("SELECT a FROM table WHERE foo = 'bar'",(-1),(-1),SQLPtr[0]); //select query in the first DB
mysql_query("UPDATE b SET bar = 'foo'",(-1),(-1),SQLPtr[1]); //update query in the second DB
mysql_close(SQLPtr[1]); //close the 2nd DB connection, the other connection still exists

mysql_debug( activat = 1 )
Activeaza-l si creaza un fisier log cu numele mysql.log

mysql_errno( [connectionHandle = 1] )
mysql_fetch_int( [connectionHandle = 1] )
mysql_fetch_field_row( string[], const fieldname[] [,connectionHandle = 1] )
mysql_fetch_float( &Float:result [,connectionHandle = 1] )
mysql_fetch_row_format( string[], const delimiter[] = "|" [,connectionHandle = 1] )
mysql_field_count( [connectionHandle = 1] )
mysql_format( [connectionHandle = 1] )
[pawn]Supoerta: (%2.f/%10.s nu sunt suportate)
- %e (scapa de date direct,fara a fi nevoie de mysql_escape_string() inainte,dar nu da si query!)
- %s (string)
- %d / %i (integer)
- %f (float)

new szDestination[100];
mysql_format(connectionHandle, szDestination, "SELECT * FROM `%s` WHERE `bar` = '%e' AND `foobar` = '%f' LIMIT %d", "foobar", "escape'me\"please", 1.2345, 1337);
//variabila 'szDestination' contine stringul fara caractere care ar purea face SQL INJECTION
mysql_query(szDestination);[/pawn]
mysql_free_result( [connectionHandle = 1] )
mysql_get_charset( destination[] [,connectionHandle = 1] )
mysql_insert_id( [connectionHandle = 1] )
mysql_num_rows( [connectionHandle = 1] )
mysql_num_fields( [connectionHandle = 1] )
mysql_ping( [connectionHandle = 1] )
Adauga return 1; daca conexiunea este activa, daca nu adauga return -1;[*]mysql_query( query[] [,resultid = (-1), extraid = (-1), connectionHandle = 1] )

Setting result id to something else than (-1), triggers the OnQueryFinish callback[*]mysql_query_callback( index, query[], callback[] [, extraid = (-1), connectionHandle = 1] )

Allows you to create custom callbacks for better structured coding (See sample_script.pwn below)[*]mysql_real_escape_string( const source[], destination[] [,connectionHandle = 1] )
[*]mysql_reconnect( [connectionHandle = 1] )
[*]mysql_reload( [connectionHandle = 1] )
[*]mysql_retrieve_row( [connectionHandle = 1] )

Returns true (1) incase there are still rows to retrieve, else false (0)[*]mysql_set_charset( charset[] [,connectionHandle = 1] )
[*]mysql_stat( const destination[] [,connectionHandle = 1] )
[*]mysql_store_result( [connectionHandle = 1] )
[*]mysql_warning_count( [connectionHandle = 1] )

Pawn Callback:
OnQueryFinish( query[], resultid, extraid, connectionHandle ) - Sample usage (updated)
This is just called if you used the 'resultid' parameter in the query function

OnQueryError( errorid, error[], resultid, extraid, callback[], query[], connectionHandle )
Compiling Notes:

Windows: Deschide fisierul de proiect cu Microsoft Visual C++ si click pe bunonul build. (MySQL Visual Studio/C++ este necesar)
Linux: Instaleaza gcc, gpp & mysql-client si scrie "make" in fisierele sursa.
Download:

Windows: (requires .NET Framework)
R6-2: Server plugin (VS9)
R6: Server plugin (VS9)
R5: Server plugin (VS9)
libmysql.dll


Linux: (x86 (32-bit) version is cross compatible)
R6-2: Ubuntu (threadsafe), x86 (compiled on Ubuntu 11.04)
R6: CentOS, Debian 5, x86 (compiled on CentOS), x86 (compiled on Debian5)
R5: CentOS, Debian 5, x86
libmysqlclient.so.15 - Getting this error.. 'libmysqlclient.so.15: cannot open shared [..]' ? - Read this[*]Scripting:

R6-2: a_mysql.inc (includes mysql_format())
R5, R6: a_mysql.inc, Sample PAWN script
Archive: PHP class, Modified sample script (by nemesis) (only R5/R6 compatible)[*]Source: (Cross-Compatible)

R7: Source code (+ new include file)
R6-2: Source code (rar), Source code (tar.bz2)
R6: Source code
R5: Source code