Generates SQL queries for MySQL and SQLite.
This library helps creating safe SQL queries to use in different plugins.
- PHP 7.4+
- libqlite 3.14+
composer require choval/builder
use choval\builder;
$builder = new builder;
$db = new SQLite3('my.db');
$db->query('CREATE TABLE user ( id INT PRIMARY KEY AUTO_INCREMENT, name TEXT )');
$userId = 1;
$user = $db->querySingle( $builder->get('user', $userId) );
$user['name'] = 'John';
$db->querySingle( $builder->save('user', $user) );
loadStructure
method to load the database structure from a JSON.fields
method for selecting the fields to retrieve. Allow functions as well.orderBy
method for adding an order/sort.groupBy
method to add grouping.having
method to filter after grouping.