Skip to content

Latest commit

 

History

History
80 lines (53 loc) · 1.68 KB

README.md

File metadata and controls

80 lines (53 loc) · 1.68 KB

Build Status Scrutinizer Code Quality

This library aims to reduce the number of method calls and promote a fast way of building query using Doctrine DBAL wrapper class, without breaking any DBAL implementation. It was inspired by NotORM.

Instalation

The recommended way to install is through Composer:

composer require abdala/reduce-database

Usage

Only set Reduce\Db\Connection as wrapperClass and that's it, you can start use it.

$db = Doctrine\DBAL\DriverManager::getConnection([
    'driver'       => 'pdo_sqlite',
    'global'       => array('memory' => true),
    'wrapperClass' => 'Reduce\Db\Connection'
]);

Select

$db->tableName(); //SELECT * FROM tableName

Where

$db->tableName[3]; //SELECT * FROM tableName WHERE id = ?
$db->tableName('name', 'Jose'); //SELECT * FROM tableName WHERE name = ?
$db->tableName('id > ?', 3); //SELECT * FROM tableName WHERE id > ?
$db->tableName([
    'name' => 'Jose', 
    'id > ?' => 3
]); //SELECT * FROM tableName WHERE name = ? AND id > ?

Tests

To run the test suite, you need Composer and PHPUnit:

./vendor/bin/phpunit

Contributing

Contributions are always welcome, please have a look at our issues to see if there's something you could help with.

License

Reduce Database is licensed under MIT license.