jbboehr/zsql

SQL generator loosely based on Zend_Db_Select

Installs: 387

Dependents: 2

Stars: 4

Watchers: 1

Forks: 1

Open Issues: 1

Language: PHP

v0.3.10 2015-07-06 23:42 UTC

README

Build Status HHVM Status Code Coverage Latest Stable Version License

Lightweight MySQL adapter and SQL generator

Install

Via Composer

composer require jbboehr/zsql

Usage

Delete

$database = new \zsql\Database($mysqli);
$database->delete()
  ->from('tableName')
  ->where('columnName', 'value')
  ->limit(1)
  ->query();

Insert

$database = new \zsql\Database($mysqli);
$id = $database->insert()
  ->ignore()
  ->into('tableName')
  ->value('columnName', 'value')
  ->value('otherColumnName', 'otherValue')
  ->query();

Select

$database = new \zsql\Database($mysqli);
$rows = $database->select()
  ->from('tableName')
  ->where('columnName', 'value')
  ->order('orderColumn', 'ASC')
  ->limit(2)
  ->offset(5)
  ->query()
  ->fetchAll();

Update

$database = new \zsql\Database($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.