Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Releases Libraries [Library] pawn-plus-mysql: PawnPlus extensions and helpers for the MySQL plugin

 
  • 0 Vote(s) - 0 Average
Library pawn-plus-mysql: PawnPlus extensions and helpers for the MySQL plugin
Graber
Offline

open.mp Developer

Posts: 31
Threads: 4
Joined: Feb 2019
Reputation: 6
Location: Germany
#1
2019-04-17, 01:38 AM
pawn-plus-mysql

[Image: sampctl-pawn--async--mysql-2f2f2f.svg?st...-the-badge]

PawnPlus extensions and helpers for the MySQL plugin

Installation

Simply install to your project:

Code:
sampctl package install AGraber/pawn-plus-mysql

Include in your code and begin using the library:

Code:
#include <pp-mysql>

It is recommended that you set a PawnPlus version explicitely on your pawn.json (preferibly the latest) to avoid always downloading the latest one.

If you don’t use sampctl, just download the pp-mysql.inc include and drop it to your includes/ folder, and then download the PawnPlus plugin and include from here.

While you’re on it and if you don’t use PawnPlus yet, you should check it out!

Usage

All existing mysql_[t/p]query now have a variant that accepts PawnPlus strings, ending with _s (for example, mysql_tquery_s).

In addition, a new member arrives into the family of these natives: mysql_aquery[_s], which returns a task that will be set as completed when the query completes successfully, or fault when there’s an error during its execution.

Note that mysql_aquery[_s] will piggyback on mysql_tquery by default. You can override this and use mysql_tquery by setting the parallel parameter at the end to true, or explicitly change this default value by defining MYSQL_ASYNC_DEFAULT_PARALLEL to you desired value.

Examples

Using PawnPlus strings on natives

PHP Code:
public OnPlayerTookAllCandies(playerid)
{
   mysql_tquery_s(DatabaseHandle, @("UPDATE player SET took_candies = UNIX_TIMESTAMP() WHERE id = ") % GetPlayerDBID(playerid));
} 

Task-based asynchronous queries:

PHP Code:
LoadPlayerData(playerid)
{
   await mysql_aquery_s(DatabaseHandle, @("SELECT * FROM player WHERE id = ") % GetPlayerDBID(playerid), .parallel = false);
   // Cache functions will be available after this
   cache_get_value_name_float(0, "health", PlayerHealth[playerid]);
   // ...
} 
#Fede
Offline

Burgershot Member
Posts: 12
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: Montevideo, Uruguay
#2
2019-04-17, 01:40 AM
Very useful!
TommyB
Offline

discord-connector #1 fan

Posts: 34
Threads: 3
Joined: Feb 2019
Reputation: 6
Location: Texas, USA
#3
2019-04-17, 02:30 AM
another incredible revolution in the pawner world
Toretto
Offline

Moderator

Posts: 40
Threads: 1
Joined: Apr 2019
Reputation: 4
#4
2019-04-17, 07:20 AM
I was waiting for this, thought it was just a joke or an idea when it was being discussed on discord. I will be using pawn plus from now on, see if I can get used to it. Thanks for the release Graber.
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#5
2019-04-20, 11:19 AM
I know pawn-plus uses this naming scheme, but please don't copy it. One thing we want to do with open.mp is promote consistency in naming schemes and styles. The argument used with pawn-plus was that the core library is inconsistent, so why can't that also be inconsistent (in a different way)? We intend to fix the core library.
kristo
Offline

Burgershot Member
Posts: 47
Threads: 10
Joined: Feb 2019
Reputation: 7
Location: Estonia
#6
2019-04-20, 12:19 PM
(2019-04-20, 11:19 AM)Y_Less Wrote: I know pawn-plus uses this naming scheme, but please don't copy it. One thing we want to do with open.mp is promote consistency in naming schemes and styles. The argument used with pawn-plus was that the core library is inconsistent, so why can't that also be inconsistent (in a different way)? We intend to fix the core library.

Actually I think it follows the naming scheme of the MySQL plugin.
JustMichael
Offline

Forum Manager

Posts: 189
Threads: 3
Joined: Feb 2019
Reputation: 17
Location: England
#7
2019-04-20, 12:22 PM
It's about time, I've been nagging you forever uwu

Best include, very much love ;)
Remember to always refer to J0sh as `J0sh...`

@ Networks/Servers
San Andreas Gaming Network (Owner/Founder)
San Andreas Gaming (Owner/Founder)
Grand Theft Cop's n Robber's (Owner)
Britannia Roleplay (Owner/Founder)
Alpine RP (Owner/Founder)
Aluminium Network (Maintainer)
AlphaDM (Tech Support)

# Services
Burgershot.gg (Forum Manager)
open.mp (Member)

~ Languages/Frameworks
Pawn, C, C++, C#, Javascript, Typescript, Lua, Python, Go, Rust, PHP, SQL,
Angular, React, Vue, Svelte, Laravel, Rocket
Graber
Offline

open.mp Developer

Posts: 31
Threads: 4
Joined: Feb 2019
Reputation: 6
Location: Germany
#8
2019-04-20, 07:27 PM
(2019-04-20, 12:19 PM)kristo Wrote:
(2019-04-20, 11:19 AM)Y_Less Wrote: I know pawn-plus uses this naming scheme, but please don't copy it. One thing we want to do with open.mp is promote consistency in naming schemes and styles. The argument used with pawn-plus was that the core library is inconsistent, so why can't that also be inconsistent (in a different way)? We intend to fix the core library.

Actually I think it follows the naming scheme of the MySQL plugin.

It comes from both mysql (the function base name) and also PawnPlus (the _s part). I was trying to make it consistent with those, although they are not consistent. What do you recommend instead?
DonutXD
Offline

Burgershot Member
Posts: 2
Threads: 0
Joined: Sep 2019
Reputation: 0
#9
2019-11-05, 02:18 AM
not work with pawnplus 1.2
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode