1. Go to this page and download the library: Download mtchabok/database library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mtchabok / database example snippets
use \Mtchabok\Database\Connection;
$connection = new Connection('mysql:host=localhost;dbname=test;charset=utf8', 'root','');
$connection = Connection::newConnection('mysql:host=localhost;dbname=test;charset=utf8', 'root','');
$connection = (new Connection())
->setDriver(Connection::DRIVER_MYSQL)
->setServer('localhost')
->setDatabase('test')
->setUser('root')
->setPass('')
->setCharset(Connection::CHARSET_UTF8)
;
class my_connection extends Connection
{
protected $_driver = Connection::DRIVER_MYSQL;
protected $_server = 'localhost';
protected $_database = 'test';
protected $_user = 'root';
protected $_charset = Connection::CHARSET_UTF8;
}
$connection = new my_connection();
$connection = new Connection\Mysql();
$connection->setDatabase('test');
use Mtchabok\Database\Select;
use Mtchabok\Database\Insert;
use Mtchabok\Database\Update;
use Mtchabok\Database\Delete;
$qSelect = $connection->newSelect('person');
$qInsert = $connection->newInsert('person');
$qUpdate = $connection->newUpdate('person');
$qDelete = $connection->newDelete('person');
$qSelect = (new Select('person'))->setConnection($connection);
$qInsert = (new Insert('person'))->setConnection($connection);
$qUpdate = (new Update('person'))->setConnection($connection);
$qDelete = (new Delete('person'))->setConnection($connection);
$qSelect = (Select::newSelect('person'))->setConnection($connection);