jbboehr/zsql

This package is abandoned and no longer maintained. No replacement package was suggested.

SQL generator loosely based on Zend_Db_Select

v0.7.2 2017-01-24 02:39 UTC

README

Build Status HHVM Status Coverage Status Latest Stable Version License

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.