PHP code example of kekos / query-builder
1. Go to this page and download the library: Download kekos/query-builder library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kekos / query-builder example snippets
QueryBuilder::setAdapter(new MySqlAdapter());
$result = QueryBuilder::select(['user', 'u'])
->columns(['u.id', 'uname' => 'username'])
->join(['user_permission', 'p'], QB::raw('p.user_id = u.id'))
->limit(5, 0)
->groupby(['u.id'])
->orderby(['username ASC', 'firstname ASC'])
->where('firstname', '=', 'Christoffer')
->whereNot('u.id', 'IN', array(2))
->toSql();
$result = QueryBuilder::select('user')
->orderby('id')
->where(function($qb) {
$qb->where('name', 'LIKE', '%chris%')
->whereOr('username', 'LIKE', '%chris%');
})
->where('active', '=', 1)
->toSql();
$result = QueryBuilder::insert('user')
->values([
'username' => 'Kekos',
'firstname' => 'Christoffer'
])
->toSql();
$result = QueryBuilder::update('user')
->set([
'username' => 'new_username',
'firstname' => 'New firstname'
])
->where('id', '=', 2)
->toSql();
$result = QueryBuilder::delete('user')
->where('id', '=', 2)
->toSql();