Jump to content

Recommended Posts

  • Administrator
Posted

MySQL Plugin R7

Original post: AICI

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:

    [*]Scripting:

    [*]Source: (Cross-Compatible)

    Daca nu intelegi ceva, posteaza aici.

    Stiu ca nu am tradus tot dar nu am avut timp. O sa-l traduc complet. ;)


    Atentie:

    Fiti foarte atenti la SQL Injection,sunt multi rau-voitori.

    https://docs.google.com/Doc?docid=0AZNlBave77hiZGNjanptbV84Z25yaHJmMjk&pli=1#Allowed_Intermediary_Character_30801873723976314

    logo.png

    ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

    • Administrator
    Posted

    scimba linku-rile ca nu sunt bune

    Mda. O sa fac un update.

    http://wiki.sa-mp.com/wiki/MySQL

    logo.png

    ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

    • 2 weeks later...
    • 9 months later...
    • 1 month later...
    Posted

    Bravp. Recomand MySQL tuturor!

    Da...dar ii destul de greu MySQL...

    A aparut deja si MySQL R6 :P fa update la main post!

    http://forum.sa-mp.com/showthread.php?t=56564

    Fara reclama in semnatura!

    • 4 months later...
    Posted

    Am reusit in sfarsit sa-l instalez. GG

    Da, multumim ca ai reinviat un topic vechi de 4 luni ..  :shocked:

    communitylogosml.png

    94.23.120.101:7778

    Posted

    Faceti un update la topic, a aparut R6-2 :) http://forum.sa-mp.com/showthread.php?t=56564&highlight=mysql

    communitylogosml.png

    94.23.120.101:7778

    • 2 weeks later...
    Posted

    PawnFox" post="110602" timestamp="1328634253"]

    Faceti un update la topic, a aparut R6-2 :) http://forum.sa-mp.com/showthread.php?t=56564&highlight=mysql

    pardon R7

    • Administrator
    Posted

    Done

    logo.png

    ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

    • 1 month later...
    Posted

    Am incercat sa dau urmatoarea comanda si uite ce am primit:

    root@SHD:/home/samp03/plugins# make mysql.so

    make: Nothing to be done for `mysql.so'.

    • 2 weeks later...
    • 2 weeks later...
    Posted

    " post="122378" timestamp="1335358519"]

    Am si eu o intreabare , la ce ajuta msql asta ?

    mysql

    http://www.cursuri-online.info/php_mysql/CeestePHPsiMySQL.htm

    • 5 months later...
    • 7 months later...
    Posted

    salut. ma poti ajuta cu o problema la pluginul mysql ?:( ....

    Pe pc merge perfect, dar cand il pun pe linux imi apare in log :

    [14:50:37]    Error: Function not registered: 'Streamer_CallbackHook'
    [14:50:37]    Error: Function not registered: 'SSCANF_Init'
    [14:50:37]    Error: Function not registered: 'SSCANF_Join'
    [14:50:37]    Error: Function not registered: 'SSCANF_Leave'
    [14:50:37]    Error: Function not registered: 'mysql_connect'
    [14:50:37]    Error: Function not registered: 'mysql_query'
    [14:50:37]    Error: Function not registered: 'mysql_store_result'
    [14:50:37]    Error: Function not registered: 'mysql_fetch_row_format'
    [14:50:37]    Error: Function not registered: 'mysql_ping'
    [14:50:37]    Error: Function not registered: 'mysql_reconnect'
    [14:50:37]    Error: Function not registered: 'mysql_real_escape_string'
    [14:50:37]    Error: Function not registered: 'mysql_num_rows'
    [14:50:37]    Error: Function not registered: 'mysql_fetch_field_row'
    [14:50:37]    Error: Function not registered: 'mysql_free_result'
    [14:50:37]    Error: Function not registered: 'CreateDynamicObject'
    [14:50:37]    Error: Function not registered: 'mysql_close'
    [14:50:37]    Error: Function not registered: 'mysql_debug'
    [14:50:37]    Error: Function not registered: 'CreateDynamicPickup'
    [14:50:37]    Error: Function not registered: 'CreateDynamic3DTextLabel'
    [14:50:37]    Error: Function not registered: 'CreateDynamicMapIcon'
    [14:50:37]    Error: Function not registered: 'SetDynamicObjectPos'
    [14:50:37]    Error: Function not registered: 'sscanf'
    [14:50:37]    Error: Function not registered: 'IsValidDynamicMapIcon'
    [14:50:37]    Error: Function not registered: 'DestroyDynamicMapIcon'
    [14:50:37]    Error: Function not registered: 'GetDynamicObjectPos'
    [14:50:37]    Error: Function not registered: 'IsValidDynamicObject'
    [14:50:37]    Error: Function not registered: 'mysql_retrieve_row'
    [14:50:37] Script[gamemodes/LcSNeT.amx]: Run time error 19: "File or function is not found"
    [14:50:37] Number of vehicle models: 0
    [14:50:36]  Loading plugin: mysql.so
    [14:50:36]   Failed (libmysqlclient_r.so.15: cannot open shared object file: No such file or directory)

    Cred ca trebuie update la plugin , dar nu gasesc unul bun / cum sa il fac sa mearga :( please help.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.