Skip to content
/ ZDB Public

A PHP database handler library based on PDO, the input can be an array or a JSON file it supports multiple queries, as well.

Notifications You must be signed in to change notification settings

zashboy/ZDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZDB


A PHP database handler class based on PDO, the input can be an array or a JSON file, it supports multiple queries, as well. (it works with mariadb and mysql)


Installation


Install with composer

  1. if you use composer you can install it if you add it to your composer.json
  2. connection parameters
    1. you can define them like global variables in your config.php
    <?php
    	define('DSN', 'host=your_hostname or unix_socket=your_info');
    	define('DBNAME', 'your_databasename');
    	define('USERNAME', 'your_username');
    	define('PASSWORD', 'your_password');
    	define('PATH', 'your/base/path');
    ?>
    1. or you can declare them in the json file (sample json in the src folder)

Manual install

  1. you can clone the repository to your hdd or server (git clone git@github.com:zashboy/ZDB.git)
  2. you need to care about the autoloading for example:
<?php
 	spl_autoload_register(function($class){
         foreach(glob('*/your-path-to-src-folder/src/class.' . $class . '.php') as $config){
             require_once ($config);
         }
 	});
 ?>
  1. see the 2. in the Install with composer list above

Usage


Where you need to get some data from the database and you would start to code the PDO query, you just need to instatiate the ZDB class and give it to your array of the variables or a path to a JSON file which contains all the data what you need.

for example with a JSON file:

<?php
	$test = new ZDB(PATH . 'filename.json', '>>currently used section<<', ['getPages' => ['select-1' => ['where' => ['name' => 'disclaimer']]]]);
?>

example with an array

$test = new ZDB(['delete'=>['tableName' => 'websites', 'where'=>['website_id'=>1]],
        'insert'=>['tableName' => 'websites', 'values'=>['website_name'=>'jsdkjsakfsa','server_name'=>'dasdadasfas','creation_date'=>'1980-11-23']]]);

If you've got your object you can find all of your responses in the data property

<?php
$test->data; // all of the data in an array;
$test->exception; //caught exceptions
$test->data->exectime //the execution time in microseconds
?>

You can find a detailed documentation on the link below

ZDB Documentation

About

A PHP database handler library based on PDO, the input can be an array or a JSON file it supports multiple queries, as well.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages