From 06ae6ef265d909a57f93026cee5ea2bb4ba3a85f Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 9 Jan 2021 13:50:50 +0300 Subject: [PATCH] readme --- README | 44 ----------------------------------- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 44 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 2a6dbd3..0000000 --- a/README +++ /dev/null @@ -1,44 +0,0 @@ -****************************************************************************** -* * -* Multi Theft Auto: San Andreas - Deathmatch * -* * -* ml_base, External lua add-on module * -* http://www.multitheftauto.com * -* * -* Copyright © 2003-2008 MTA. All Rights Reserved. * -* * -****************************************************************************** - -* INTRODUCTION - This is the 'ml_base' module that exports the standard interface used by - the Multi Theft Auto: San Andreas Deathmatch server and it's Lua scripting - engine to allow C/C++ developers to add functionality to their servers. - - You can use this code as a base to create your own modules, provided that - you adhere to the licensing terms provided with this source code. - -* INSTALLATION - In order to install your module, first make sure it compiles correctly and - verify that it can be executed. When using external library dependencies - in the form of a shared library (.so or .dll file) you will have to place - the library inside the directory of the MTA:SA DM server executable. - - To load your module at server initialisation, use the module configuration - tag syntax as specified in your mtaserver.conf file: - - - - - Place your module library inside the mods/deathmatch/modules directory. - Be sure to create this directory if it does not exist. - -* LICENSING - Please read the LICENSE file for any licensing information. - -* MORE INFORMATION - More information about Multi Theft Auto scripting and/or module development - can be found on any of the following URLs: - - http://www.mtasa.com/ - http://www.multitheftauto.com/ - http://development.mtasa.com/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..56ed51f --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# MTA PostgreSQL driver + +# Decription +Just a pgsql module for mta. +I accept any help with developing the module. Feel free to make PRs and Issues. + +# Installation +### Windows +Put misc files from Releases to `server\x64\` make a `modules` directory and put the `ml_pgsql.dll` file there. +### Linux +Not yet. + +# Functions +## userdata pg_conn(string connection) +Make a connect to your postgres server. +String can be like: +`postgresql://USER:PASSWORD@IP:PORT/dbname?connect_timeout=3` +or +`hostaddr=IP port=5432 dbname=DBNAME user=USERNAME password=PASSWORD` +**return** userdata with connect in sucsessful connection. or bool and string with error otherwise. +```lua +local conn,err = pg_conn("postgresql://user:123qwe@127.0.03:5432/mydb?connect_timeout=3"); +if (err ~= nil) then + print(error) + return 1; +end +``` +## userdata pg_query(userdata connection, string query) +Query data from a query string. String escaping is support. +**return** userdata with a query. Otherwise bool and string error. +```lua +local query,qerr = pg_query(conn, "SELECT $1 as a, $2 as b", -67, 2) +if (query == false) then + iprint(qerr) +end +``` +## table pg_poll(userdata query) +Get data from the userdata to the array +**return** a table or TODO +```lua +local query,qerr = pg_query(conn, "SELECT $1 as a, $2 as b", -67, 2) +if (query == false) then + iprint(qerr) +end +iprint(pg_poll(query)); +``` +## bool pg_free(userdata query) +Free a memory after executing query (if it don't happens) +**return** true +```lua +local query,qerr = pg_query(conn, "SELECT $1 as a, $2 as b", -67, 2) +pg_free(quey) +``` +## bool pg_exec(userdata connection, string query) +Like a pg_query it make a query, but do not return any data. +**return** bool as a result of executing the query. Otherwise bool and string error. +```lua +local exec = pg_exec(conn, "INSERT INTO users (name, password, money) VALUES ($1,$2,$3)", "a man", "mypasswd", "13"); +iprint(exec); +``` +## bool pg_close(userdata connection); +Close a database connection. +**return** boolean +```lua +local conn,err = pg_conn("postgresql://user:123qwe@127.0.03:5432/mydb?connect_timeout=3"); +... +pg_close(conn); +``` \ No newline at end of file