RevolveR DBX: simple MySQLi engine with structure based queries syntax

In mention to develop CMS I was write some PHP class for work with database queries based on principles of structured array definitions.

What is RevolveR DBX? It's just clever wrapper for PHP based MySQLi engine with simple configuring and very fast execution that allow you to write DB structure and define what query parameters need to be executed(all in one structured array).

Example:

// DEBUG
ini_set('error_reporting', E_ALL);
 
// CONNECT DB
require_once './DBX.php';
 
// DEBUG
ini_set('error_reporting', E_ALL);
 
// CONNECT DB
require_once './DBX.php';
 
// DB connection data
// [0] - host
// [1] - username
// [2] - password
// [3] - database name
// [4] - port
$dbx_data  = ['localhost', 'root', 'root', 'RR', '8889'];
 
// query method
// [s] - select :: s|order_by|asc|limit|offset || s|order_by|dsc|limit|offset
// [d] - drop
// [i] - insert
// [u] - update
// [x] - delete
// [t] - truncate 
// [c] - create 
 
//$dbx_query = 'i';
//$dbx_query = 'u';
$dbx_query  = 's|field_id|asc|100|1';
//$dbx_query = 'x';
 
$dbx_table = 'test';
 
// DBX FIELDS SYNTAX
$dbx_fields = [
    'field_id' => [
        'type'   => 'num',     // VARCHAR
        'auto'   => true,      // AUTO INCREMENT
        'length' => 255,       // LENGTH
        'fill'   => true,      // NOT NULL
        'value'  => 444,       // VALUE
    ],
 
    'field_0' => [
        'type'     => 'text',            // INT
        'length'   => 10,                // LENGTH
        'fill'     => false,             // !NOT NULL
        'value'    => 'TEST',            // VALUES
        'new_value' => 'YO',            // VALUE TO UPDATE
        'criterion_field' => 'field_id', // CRITERION FOR DELETE & UPDATE
        'criterion_value' => '444'    // CRITERION VALUE FOR UPDATE
    ],
 
    'field_1' => [
        'type'   => 'time', // TIMESTAMP
        'value'  => date('Y-m-d')
    ]
];
 
// NEW DB
$dbx = new DBX($dbx_data);
 
$dbx::query($dbx_query, $dbx_table, $dbx_fields);
 
print '<pre>';
print_r( $dbx::$result );
print '<pre>';

You can see very simple DB structure defined as array. Using additional parameters you can define what query DBX need to execute and how.

$dbx_query  = 's|field_id|asc|100|1';

For example we have to look at select query example: s - method, field_id - order by value, asъ or desc is a sorting priority and limit with offset values.

Now to get result you need only few strings of code:

// NEW DB
$dbx = new DBX($dbx_data);
 
$dbx::query($dbx_query, $dbx_table, $dbx_fields);
 
print '<pre>';
print_r( $dbx::$result );
print '<pre>';

If all done right you have to see next result:

MySQL query execution example

This is an execution result and some debug info thats can be helpful to develop.

In next releases I have to add JOIN support and JSON DB support this comes with MySQL 5.7.x version.

Code placed on GitHub:

Добавить комментарий