PHP Classes

Revolver DBX: Compose MySQLi queries based on parameter values

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 106 This week: 1All time: 9,677 This week: 560Up
Version License PHP version Categories
revolver_dbx 1.0MIT/X Consortium ...5PHP 5, Databases
Description 

Author

This class can compose MySQLi queries based on parameter values.

It can connect to a MySQL database server using the MySQLi extension and execute SQL queries composed using parameter values that define tables, fields, values and conditions.

Currently the class can compose SQL SELECT, INSERT, UPDATE and DELETE queries.

Picture of Dmitry Maltsev
Name: Dmitry Maltsev <contact>
Classes: 1 package by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 4392124 in Russian Federation Russian Federation
Week rank: 416 Up24 in Russian Federation Russian Federation Up

Example


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>DBX Examples Page and UNIT TESTS | CyberX.pro</title>

    <style type="text/css">
        body, html {
            padding: 0;
            margin: 0;
            background: #f0f0f0;
            font: normal 14px Verdana;
        }
        main {
            width: 1110px;
            margin: 0 auto;
        }

        h1 {
            color: darkgreen;
        }

        h2 {
            color: orange;
        }

        p {
            color: #999;
        }
    </style>

</head>
<body>

    <main>

<?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', 'dbx_test', '8889'];

// New DBX instance
$dbx = new DBX($dbx_data);

?>

<h1>[1] Example `create table` DBX structure</h1>
<section>

<?php
/**
  * CREATE TABLE EXAMPLE
  */

$table_1 = 'example'; // table name
$query_1 = 'c'; // create table sql

$fields_1 = [
   
'field_id' => [
       
'type' => 'num', // int
       
'auto' => true, // auto increment
       
'length' => 255,
       
'fill' => true // not null
   
],
   
'field_text' => [
       
'type' => 'text', // varchar
       
'length' => 255,
       
'fill' => true
   
],
   
'field_date' => [
       
'type' => 'time', // TIMESTAMP
       
'value' => date('Y-m-d')
    ]
];

// perform queries
$dbx::query($query_1, $table_1, $fields_1);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_1 );
    print
'</code></pre>';

   
// print result
   
print '<h2>DBX QUERY RESULT</h2>';
    print
'<pre><code>';
   
print_r( $dbx::$result );
    print
'</code><pre><hr />';
?>
</section>

<h1>[2] Example `drop table` DBX structure</h1>
<section>

<?php
// perform queries
$dbx::query('d', $table_1, $fields_1);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_1 );
    print
'</code></pre>';

   
// print result
   
print '<h2>DBX QUERY RESULT</h2>';
    print
'<pre><code>';
   
print_r( $dbx::$result );
    print
'</code><pre><hr />';

   
$dbx::query('c', $table_1, $fields_1);
?>
</section>

<h1>[3] Example `insert in table` DBX structure</h1>
<section>

<?php

// fields values for table_1 example
$fields_2 = [
   
'field_id' => [
       
'value' => 456
   
],
   
'field_text' => [
       
'value' => 'I have to add into my table'
   
],
   
'field_date' => [
       
'value' => date('Y-m-d')
    ]
];

// perform queries
$dbx::query('i', $table_1, $fields_2);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_2 );
    print
'</code></pre>';

   
// print result
   
print '<h2>DBX QUERY RESULT</h2>';
    print
'<pre><code>';
   
print_r( $dbx::$result );
    print
'</code><pre><hr />';

?>

</section>

<h1>[3-1] Example `inject [auto UPDATE or INSERT] in table` DBX structure </h1>

<p>Simple provide an AUTO INCREMENT field value of 0 to perform INSERT query. If AUTO INCREMENT field value are exists will be performed UPDATE query.</p>

<section>

<?php

// fields values for table_1 example
$fields_2 = [
   
'field_id' => [
       
'value' => 0
   
],
   
'field_text' => [
       
'value' => 'Yo if field_id = 0 it\'s an insert or if id exists it\'s an update'
   
],
   
'field_date' => [
       
'value' => date('Y-m-d')
    ]
];

// perform queries
$dbx::query('in', $table_1, $fields_2);

?>


<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_2 );
    print
'</code></pre>';

   
// print result
   
print '<h2>DBX QUERY RESULT</h2>';
    print
'<pre><code>';
   
print_r( $dbx::$result );
    print
'</code><pre><hr />';

?>
</section>


<h1>[4] Example `update in table` DBX structure</h1>
<section>

<?php

// fields values for table_1 example
$fields_3 = [
   
'field_id' => [
       
'value' => 456
   
],
   
'field_text' => [
       
       
'new_value' => 'I was updated',

       
'criterion_field' => 'field_id',
       
'criterion_value' => 456

   
],
   
'field_date' => [
       
'value' => date('Y-m-d')
    ]
];

// perform queries
$dbx::query('u', $table_1, $fields_3);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_3 );
    print
'</code></pre>';

   
// print result
   
print '<h2>DBX QUERY RESULT</h2>';
    print
'<pre><code>';
   
print_r( $dbx::$result );
    print
'</code><pre><hr />';

?>
</section>

<h1>[5] Example `select in table` DBX structure</h1>
<section>

<?php

// perform queries
$dbx::query('s|field_id|asc|100|0', $table_1, $fields_1);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_1 );
    print
'</code></pre>';

   
// print result
   
print '<h2>DBX QUERY RESULT</h2>';
    print
'<pre><code>';
   
print_r( $dbx::$result );
    print
'</code><pre><hr />';

?>
</section>

<h1>[6] Example `delete from table` DBX structure</h1>
<section>

<?php

// fields values for table_1 example
$fields_3 = [
   
'field_id' => [
       
'value' => 456
   
]
];

// perform queries
$dbx::query('xd', $table_1, $fields_3);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_3 );
    print
'</code></pre>';

?>
</section>

<h1>[7] Example `truncate from table` DBX structure</h1>
<section>

<?php

// perform queries
$dbx::query('t', $table_1, $fields_3);
$dbx::query('d', $table_1, $fields_3);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_3 );
    print
'</code></pre><hr />';
?>
</section>

<h1>[8] Example `drop from table` DBX structure</h1>
<section>
<?php

// perform queries
$dbx::query('d', $table_1, $fields_3);

?>

<?php
   
// print structure
   
print '<h2>DBX STRUCTURE</h2>';
    print
'<pre><code>';
   
print_r( $fields_3 );
    print
'</code></pre><hr />';
?>
</section>

    </main>

</body>
</html>


Details

Revolver_DBX

RevolveR DBX is a DataBase engine(PHP mysqli) allows you to perform queries fast and simple on STRUCTURE array based syntax.

v.1.1.1 :: added INJECT queries with autoupdate or insert aligement and file based autocache(refreshed on every DB change).

For examples see index.php with structures examples and queries debug.


  Files folder image Files  
File Role Description
Files folder imageprivate (1 directory)
Plain text file DBX.php Class Class source
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  private  
File Role Description
Files folder imagecache (1 file)

  Files folder image Files  /  private  /  cache  
File Role Description
  Accessible without login Plain text file example.cache Data empty cache

 Version Control Unique User Downloads Download Rankings  
 100%
Total:106
This week:1
All time:9,677
This week:560Up