1. Go to this page and download the library: Download didslm/sql-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/ */
didslm / sql-builder example snippets
slm\QueryBuilder\SelectQueryBuilder;
$query = SelectQueryBuilder::from('users')
->select('*')
->where('age', 18)
->build();
echo $query; // Outputs: SELECT * FROM users WHERE age = 18
$query = SelectQueryBuilder::from('users')
->select('*')
->join('posts', 'users.id', 'posts.user_id')
->where('users.age', 18, '>')
->where('posts.published', true)
->build();
echo $query; // Outputs: SELECT * FROM users JOIN posts ON users.id = posts.user_id WHERE users.age > 18 AND posts.published = true
$sql = SelectBuilder::from('users')
->where('name', 'John')
->and('age', 18)
->and('email', 'selimi')
->or('name', 'test')
->and('email', 'selimi')
->build();
echo $sql; // Outputs: SELECT * FROM users WHERE (name = 'John' AND age = 18 AND email = 'selimi') OR (name = 'test' AND email = 'selimi')
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.