Giter Club home page Giter Club logo

pawn-plus-mysql's Introduction

pawn-plus-mysql

sampctl

PawnPlus extensions and helpers for the MySQL plugin

Installation

Simply install to your project:

sampctl package install AGraber/pawn-plus-mysql

Include in your code and begin using the library:

#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

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

Task-based asynchronous queries:

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]);
	// ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.