Skip to content
/ ezsql Public

An easy-to-use and IDE friendly SQL builder. Object-oriented SQL

License

Notifications You must be signed in to change notification settings

caoym/ezsql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status GitHub license

ezsql

An easy-to-use and IDE friendly SQL builder

HOW TO USE

$db = new \PDO($dsn, $username, $passwd);

SELECT

$res = Sql::select('a, b')
   ->from('table')
   ->leftJoin('table1')->on('table.id=table1.id')
   ->where('a=?',1)
   ->groupBy('b')->having('sum(b)=?', 2)
   ->orderBy('c', Sql::$ORDER_BY_ASC)
   ->limit(0,1)
   ->forUpdate()->of('d')
   ->get($db);

UPDATE

$rows = Sql::update('table')
   ->set('a', 1)
   ->where('b=?', 2)
   ->orderBy('c', Sql::$ORDER_BY_ASC)
   ->limit(1)
   ->exec($db)
   ->rows

INSERT

$newId = Sql::insertInto('table')
   ->values(['a'=>1])
   ->exec($db)
   ->lastInsertId()

DELETE

$rows = Sql::deleteFrom('table')
   ->where('b=?', 2)
   ->orderBy('c', Sql::$ORDER_BY_ASC)
   ->limit(1)
   ->exec($db)
   ->rows

About

An easy-to-use and IDE friendly SQL builder. Object-oriented SQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages