SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 05/01/2019, 12:10 PM   #6141
Heloo12017
Little Clucker
 
Join Date: Dec 2018
Location: Romania
Posts: 6
Reputation: 0
Default Re: [REL] MySQL Plugin (Now on github!)

Very nice
Heloo12017 is offline   Reply With Quote
Old 21/01/2019, 03:08 PM   #6142
OuDayas
Big Clucker
 
Join Date: Jan 2019
Posts: 78
Reputation: 0
Default Re: [REL] MySQL Plugin (Now on github!)

It's possible save and load an enum from db?
for a register and login system, I saved in the db a variable in enum type F and M, and Im using this https://github.com/pBlueG/SA-MP-MySQ...stem-cache.pwn
how can I set a code for save and load an enum?

Quote:
Originally Posted by BlueG View Post
MySQL Plugin
The best and most famous MySQL plugin for SA:MP out there!

Code:
10/12/2013:
The project has been moved from ******code to github

This plugin allows you to use MySQL in PAWN. It's currently being developed by Pain123/maddinat0r; you'll find all older versions, including source codes and sample scripts, from R5 to R7 at the bottom of this post and the latest release here.




How to install:


Move mysql.dll (windows) or mysql.so (linux) to your 'plugins/' directory. On windows you'll have to download the mysql library (libmysql.dll, see downloads) and move it to your main server directory. The server configuration (server.cfg) has to be edited aswell.
  • Windows
    Code:
    plugins mysql
  • Linux
    Code:
    plugins mysql.so


PAWN Scripting R5-R7: (a_mysql.inc)
  • Native functions: (All parameters in squared brackets are optional)
  • * = R5, R6 (supports threaded and non-threaded scripts)
  • * = R7 (supports only threaded scripts)
  • Caching guide - Click!

    • mysql_affected_rows( [connectionHandle = 1] ) **
    • mysql_close( [connectionHandle = 1] ) **
      • Make sure you call this on OnGameModeExit()/OnFilterscriptExit()
    • mysql_connect( const host[], const user[], const database[], const password[] ) *
    • mysql_connect( const host[], const user[], const database[], const password[] [, port = 3306] ) *
      • Returns a connection handle you can use for multiple connections
    • mysql_debug( enable = 1 ) **
      • Enables the debug modus and creates a log file named 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, output[], format[], {Float,_}:... ) * (works on R6-2 aswell)
      pawn Code:
      Supported formats: (including precisions)
      - %e (escapes a string at once, no mysql_real_escape_string() needed)
      - %s (string)
      - %d / %i (integer)
      - %f (float)
      - %x (hex)
      - %b (binary)

      new szDestination[100];
      mysql_format(connectionHandle, szDestination, "SELECT * FROM `%s` WHERE `bar` = '%e' AND `foobar` = '%.2f' LIMIT %d", "foobar", "escape'me\"please", 1.2345, 1337);
      // the variable 'szDestination' contains now the formatted query (including the escaped string)
      mysql_query(szDestination);
    • 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] ) **
      • Returns true (1) if the connection is alive, else (-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] ) **
    • cache_get_row( row, idx, dest[] [, connectionHandle = 1] ) *
    • cache_get_field( field_index, dest[] [, connectionHandle = 1] ) *
    • cache_get_data( &num_rows, &num_fields [, connectionHandle = 1] ) *
    • cache_get_field_content( row, const field_name[], dest[] [, connectionHandle = 1] ) *
    • enable_mutex( bool:enable ) *
      • Disable mutexes incase you experience random crashes. (seems to happen on some linux distros only)
    • mysql_function_query( connectionHandle, query[], bool:cache, callback[], format[], {Float,_}:... ) *
      pawn Code:
      mysql_function_query(connectionHandle, "UPDATE `foo` SET `bar` = 1", false, "CustomResponse", "dsf", 1337, "string", 1.5634);

      public CustomResponse(integer, string[], Float:float)
      {
          printf("Query successful executed. Data: %d | %s | %f", integer, string, float);
          return 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 ) *
    • OnQueryError( errorid, error[], callback[], query[], connectionHandle ) *


Compiling Notes:
  • Windows: Open the project file with Microsoft Visual C++ and click the build button. (MySQL Visual Studio/C++ is required of course)
  • Linux: Install gcc, gpp & mysql-client and type "make" in the source files folder.

Downloads: (for newer updates, use the github project site above!)

NOTE: DON'T USE VERSION R7 OR ABOVE IF YOU HAVE NO IDEA WHAT THREADING MEANS OR HOW IT WORKS. YOU MIGHT HARM YOUR SERVER WHEN USING IT NOT PROPERLY.

Thanks to:
  • Chaprnks, Gehaktbal, JaTochNietDan, LS:RP Tester team, Webflori (Testing)
  • AndreT (Testing/Cache Tutorial)
  • JernejL (Testing/Suggestions)
  • krisk (Testing/Suggestions)
  • Kye (Coding support)
  • Mow (Compiling/Testing/Hosting)
  • nemesis (Testing)
  • Pain123 (Developing the plugin as of R
  • Sergei (Testing/Suggestions/Wiki documentation)
  • xxmitsu (Testing/Compiling)

If you have any questions, post them here!
OuDayas is offline   Reply With Quote
Old 29/01/2019, 05:34 PM   #6143
NoorMustafa123
Little Clucker
 
NoorMustafa123's Avatar
 
Join Date: May 2017
Location: idk
Posts: 49
Reputation: 6
Default Re: [REL] MySQL Plugin (Now on github!)

PHP Code:
[14:22:15] [debugServer crashed due to an unknown error
[14:22:15] [debugNative backtrace:
[
14:22:15] [debug#0 f5653a5b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[14:22:15] [debug#1 f564c852 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[14:22:15] [debug#2 f564d35c in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[14:22:15] [debug#3 f564d86e in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[14:22:15] [debug#4 f565376d in ?? () from plugins/crashdetect.so
[14:22:15] [debug#5 f7745420 in ?? ()
[14:22:15] [debug#6 f73af5be in _ZN12CMySQLHandleD1Ev () from plugins/mysql.so
[14:22:15] [debug#7 f73af885 in _ZN12CMySQLHandle7DestroyEv () from plugins/mysql.so
[14:22:15] [debug#8 f73af8f3 in _ZN12CMySQLHandle8ClearAllEv () from plugins/mysql.so
[14:22:15] [debug#9 f73c9212 in Unload () from plugins/mysql.so
[14:22:15] [debug#10 080d210b in ?? () from ./samp03svr
[14:22:15] [debug#11 080aa237 in ?? () from ./samp03svr
[14:22:15] [debug#12 f7409af3 in __libc_start_main () from /lib/i386-linux-gnu/libc.so.6
[14:22:15] [debug#13 0804b4e1 in ?? () from ./samp03svr 
any idea of this crash? crashdetect said that

EDIT: Fixed.
__________________
My Works
[Maps] Area 51 | Desert Airport | A Small Island |

Last edited by NoorMustafa123; 24/03/2019 at 11:22 AM.
NoorMustafa123 is offline   Reply With Quote
Old 29/04/2019, 11:09 PM   #6144
NATANGameron
Big Clucker
 
NATANGameron's Avatar
 
Join Date: Mar 2017
Location: Includes/World.inc
Posts: 161
Reputation: 1
Default Re: [REL] MySQL Plugin (Now on github!)

Please create a static version for CentOS, at the start I get the error: Failed (/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by plugins/mysql.so))
I tried everything to install but it does not work!
__________________

Nunca desista de seus sonhos, é só tenta que você chega la.
NATANGameron is offline   Reply With Quote
Old 30/04/2019, 08:46 PM   #6145
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 869
Reputation: 73
Default Re: [REL] MySQL Plugin (Now on github!)

Quote:
Originally Posted by NATANGameron View Post
Please create a static version for CentOS, at the start I get the error: Failed (/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by plugins/mysql.so))
I tried everything to install but it does not work!
What version of the plugin are you trying to use and what CentOS release are you using?
__________________
Jeroen52 is offline   Reply With Quote
Old 11/07/2019, 09:22 PM   #6146
=KempeR=
Huge Clucker
 
=KempeR='s Avatar
 
Join Date: Oct 2011
Location: Kyiv, Ukraine
Posts: 253
Reputation: 7
Default Re: [REL] MySQL Plugin (Now on github!)

Will the latest version of the plugin work with the new MySQL 8.0?
__________________
Dafuq am I still doing in SA-MP in 2018?

Sincerely, Kemper
=KempeR= is offline   Reply With Quote
Old 12/07/2019, 09:22 AM   #6147
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 569
Reputation: 92
Default Re: [REL] MySQL Plugin (Now on github!)

Quote:
Originally Posted by =KempeR= View Post
Will the latest version of the plugin work with the new MySQL 8.0?
Yes.
Calisthenics is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
****** Project: Glass int3s0 Everything and Nothing 99 26/02/2013 04:22 PM
MySQL Plugin R5 plugin problem dud Scripting Help 12 05/12/2011 06:28 PM
Strikens Mysql vs BlueG's Mysql plugin PrawkC Scripting Help 4 30/09/2011 10:30 AM
[help][plugin] Can't load mysql plugin mariomako Help Archive 8 16/07/2011 02:37 PM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 02:32 PM


All times are GMT. The time now is 10:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.