Jump to content
Sign in to follow this  
-=[Vyorel]=-

MySQL Plugin R5

Recommended Posts

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


    Romanian Power Hosting - www.RO-PH.com

    TruckersMP Romania - www.TruckersMP.ro

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

    Share this post


    Link to post
    Share on other sites

    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

    Share this post


    Link to post
    Share on other sites

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

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

    mysql

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

    Share this post


    Link to post
    Share on other sites

    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.

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...

    Important Information

    This site uses cookies. By continuing browsing, you agree to the use of this information. For more details, see Terms of Use and Privacy Policy.