Jump to content
code34

OO_extDB2 - A driver for extDB2 addon (Mysql/Sqlite)

Recommended Posts

OO_extDB2 - A driver for extDB2 addon (Mysql/Sqlite)
Lastest version : 0.1 by Code34

Download from : Dropbox

Download from : Armaholic

Like to donate ? with Paypal


GitHub : https://github.com/code34/oo_extDB2.Altis
 



OO_extDB2 is a driver for extDB2 addon.

Features
    - Facilitate the use of extDB2 by giving ready to go methods.
    - Standardize methods name and return value

Licence
Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author


Example

Quote

    call compile preprocessFileLineNumbers "oo_extdb2.sqf";

    sleep 2;

    /*
    Example 1 with a standard SQL QUERY

    _extdb2 = ["new",  ["test_database"]] call OO_extDB2;

    ["setMode", ["SQLQUERY"]] call _extdb2;
    
    _query = "SELECT * FROM test_table_1";
    _result = ["executeQuery", [_query, []]] call _extdb2;  
    
    hint format ["SQL QUERY: %1", _result];
    */


    /*
    Example 2 with a PREPARED STATEMENT

    _extdb2 = ["new",  ["test_database", "extDB2"]] call OO_extDB2;

    ["setMode", ["PREPAREDSTATEMENT"]] call _extdb2;

    _result = ["executeQuery", ["Player_GetByUID2", []]] call _extdb2;

    hint format ["PREPARED STATEMENT: %1", _result];
    */

 

Documentation

 

Quote

    Description:
    CLASS OO_extDB2 - A driver for extdb2

    Authors:  
    code34 nicolas_boiteux@yahoo.fr
    Aloe <itfruit@mail.ru>

    Copyright © 2016 Nicolas BOITEUX
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    --------------------------------------------------------------------------------------------------------------

    Function:  _extdb2 = ["new", ["mydbname", "preparedstatementconfigfile"]] call OO_extDB2;
    Create a new extdb2 mapper
        
    Parameters: array
        _this select 0 : string - containing your dbname as it is declared into the file "extdb-conf.ini"
        _this select 1 : string - name of the file containing all the prepared statement without .ini extension (optionnal - by default the file name is "extDB2" in @extDB2\extDB\sql_custom_v2).
            This file is only used if you used the "PREPAREDSTATEMENT" mode

    --------------------------------------------------------------------------------------------------------------

    Function: _bool = ["setMode", [_mode, _options]] call _extdb2;
    Set the Mode used for db queries

    Parameters: array
        _this select 0: string - mode can be "PREPAREDSTATEMENT" or "SQLQUERY"
            PREPAREDSTATEMENT are SQL Query pre declared in the .ini file (recommanded as they return a formated result)
            SQLQUERY are standard SQL query (deprecated)
        _this select 1: string - option if use by PREPAREDSTATEMENT and is optionnal
            More infos : https://github.com/Torndeco/extDB2/wiki/Calls:-Protocol--SQL_CUSTOM_V2
        
    Return : true if success

    --------------------------------------------------------------------------------------------------------------

    Function: _result = ["executeQuery", [_query, _defaultreturn]] call _extdb2;
    Execute the SQL Query
        
    Parameters: array
        _this select 0 : string - SQL QUERY in SQLQUERY mode or name of prepared statement
        _this select 1 : string|scalare|bool|array, default return value expected if no result is found, or database is broken

    Return :  result of the query or default value
    
    --------------------------------------------------------------------------------------------------------------
    
    Function:  ["delete", _extDB2] call OO_extDB2;
    Destroy the extDB2 object
        
    Parameters:
        object - extDB2 object
    
    Return : nothing

 

 

Readme

 

 

Quote

    Description:
    CLASS OO_extDB2 - A driver for extdb2

    Authors:  
    code34 nicolas_boiteux@yahoo.fr
    Aloe <itfruit@mail.ru>

    Copyright © 2016 Nicolas BOITEUX
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    How to install:
    1- Install the extDB2 addons: https://github.com/Torndeco/extDB2/releases
        move "@extDB2" folder  into your ARMA3 root directory
        move tbbmalloc.dll into the ARMA3 root directory
        create @extDB2/extDB/ directory
    2- Configure @extDB2/extdb-conf.ini with the type, name of your database / login / password / port etc
    3- if you use prepared statement queries (recommanded instead standard sql queries)
        1 - create the @extDB2/extDB/sql_custom_v2 directory
        2 - put in this directory, the file from : https://github.com/Torndeco/extDB2/blob/master/examples/sql_custom_v2/example.ini
        3 - rename it like "extDB2.ini"
        4 - configure it
    4- if use :
        sqlite: create the  @extDB2/extDB/sqlite directory
            1 - put your sqlite db file inside
        mysql: your database should be installed and configured
    4- put the "oo_extDB2.sqf" and the "oop.h" files in your mission directory
    5- put this code once into your mission init.sqf :
        call compilefinal preprocessFileLineNumbers "oo_extDB2.sqf";

    Change log:
        V 0.1 : first release

  • Like 1

Share this post


Link to post
Share on other sites

As far as I know, few people actually use real databases. From what I've heard so far, many scripters rely on plain and simple data persistence, such as iniDB.

 

I personally consider iniDB horrible compared to the power and speed of an actual database, but nevertheless, maybe most people, if they use extDB, just use it as-is and don't see the need for an OO wrapper as you created it. :unsure:

  • Like 1

Share this post


Link to post
Share on other sites

wow interesting feedback, you don't use it , and dont see interest to use it, and last thing my other work is horrible.

 

Nice positive attitude :) Anyway, i think guys use them cause it s simple, and they don't have to spend time to develop things that they need as plug and usable.

Share this post


Link to post
Share on other sites

You are obviously making the effort to bring object orientation to a non-object-oriented language which is a great thing if you ask me, because I honestly miss it in SQF. Having said that, I've never really used it yet, only watched your code to find out, how you've done it. ^_^

 

It's just that I've learned very quickly, how powerful databases are and I wouldn't wanna miss SQL for persisting text and numbers like in case of ArmA 3. The only reason(s) I can imagine why people would not use a true database for persisting data, is that they either don't want to learn SQL or they simply don't care how their data is stored as long as it's stored at all.

 

I hope you can understand why I cannot like iniDB. Sorry, don't mean to offend you.

Share this post


Link to post
Share on other sites

you don't offend me :) both systems are not done for the same use. Many things, can lead you to use one instead an other.

 

I assume that peoples who come read this thread have already did their choices and looking for a simply way to start with extDB2.

Share this post


Link to post
Share on other sites

Hello

 

For who is interested by im working on a oo_extdb3 driver version.

 

Is there any testers for this ? :)

 

 

Share this post


Link to post
Share on other sites

Hi

 

I just release the new version OO_EXTDB3

 

OO_EXTDB2 is depricated and not any more supported.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×