1. Go to this page and download the library: Download masterweber/sqlbuilder 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/ */
masterweber / sqlbuilder example snippets
use SQLBuilder\SQLBuilder;
use SQLBuilder\Expression\Column;
use SQLBuilder\Clause\OrderBy;
$builder = new SQLBuilder();
$sql = $builder->select(['t1.column' => 'col1','t2.column' => 'col2'])
->from(['table1' => 't1'])
->join(['table2' => 't2'])
->right()
->on()
->equal('col1', Column::from('t2.col3'))
->where()
->isNotNull('col1')
->orderBy('col2', OrderBy::DESC)
->limit(10)
->offset(10);
use SQLBuilder\SQLBuilder;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->insertInto('table_name')->values([5, 2]);
use SQLBuilder\SQLBuilder;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->insertInto('table_name')
->columns(['first', 'second'])
->values([5, 2]);
use SQLBuilder\SQLBuilder;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->insertInto('table_name')->default();
use SQLBuilder\SQLBuilder;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->select()
->from('table_name')
->where()
->equal('column', 5)
->limit(17)
->offset(10);
use SQLBuilder\SQLBuilder;
use SQLBuilder\Expression\Column;
use SQLBuilder\Clause\OrderBy;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->select(['t1.column' => 'col1','t2.column' => 'col2'])
->distinct()
->from(['table1' => 't1'])
->join(['table2' => 't2'])
->right()
->on()
->equal('col1', Column::from('t2.col3'))
->where()
->isNotNull('col1')
->orderBy('col2', OrderBy::DESC)
->limit(12745);
use SQLBuilder\SQLBuilder;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->update('table_name')
->set(['col1' => 1, 'date' => '2000-01-01'])
->where(['id' => 5])
->limit(1);
use SQLBuilder\SQLBuilder;
$sqlBuilder = new SqlBuilder();
$sql = $sqlBuilder->delete()
->from('table_name')
->where()
->equal('col1', 2)
->and()
->equal('col2', 23)
->limit(3);
sql
UPDATE `table_name` SET `col1` = 1, `date` = '2000-01-01' WHERE `id` = 5 LIMIT 1
sql
DELETE FROM `table_name` WHERE `col1` = 2 AND `col2` = 23 LIMIT 3
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.