jbboehr / zsql
SQL generator loosely based on Zend_Db_Select
Installs: 3 432
Dependents: 3
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: >=5.3.0
Requires (Dev)
- apigen/apigen: 2.8.*
- jbboehr/coding-standard: 1.0.*@dev
- phpunit/phpunit: ~4.5.0
- psr/log: ~1.0
- satooshi/php-coveralls: ~1.0.0
- squizlabs/php_codesniffer: ~2.3.2
This package is not auto-updated.
Last update: 2022-02-01 12:24:56 UTC
README
Lightweight MySQL adapter and SQL generator
Install
Via Composer
composer require jbboehr/zsql
Usage
Delete
$database = new zsql\Adapter\MysqliAdapter($mysqli); $database->delete() ->from('tableName') ->where('columnName', 'value') ->limit(1) ->query();
Insert
$database = new zsql\Adapter\MysqliAdapter($mysqli); $id = $database->insert() ->ignore() ->into('tableName') ->value('columnName', 'value') ->value('otherColumnName', 'otherValue') ->query();
Select
$database = new zsql\Adapter\MysqliAdapter($mysqli); $rows = $database->select() ->from('tableName') ->where('columnName', 'value') ->order('orderColumn', 'ASC') ->limit(2) ->offset(5) ->query() ->fetchAll();
Update
$database = new zsql\Adapter\MysqliAdapter($mysqli); $database->update() ->table('tableName') ->set('columnName', 'value') ->set('someColumn', new zsql\Expression('NOW()')) ->where('otherColumnName', 'otherValue') ->limit(1) ->query();
Basic SQL or Custom Database Adapter
See Adapters.md
Testing
make test
License
This project is licensed under the MIT license.