1. Go to this page and download the library: Download requtize/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/ */
requtize / query-builder example snippets
use Requtize\QueryBuilder\Connection;
use Requtize\QueryBuilder\QueryBuilder\QueryBuilderFactory;
use Requtize\QueryBuilder\ConnectionAdapters\PdoBridge;
// Somewhere in our application we have created PDO instance
$pdo = new PDO('dns...');
// Build Connection object with PdoBridge ad Adapter
$conn = new Connection(new PdoBridge($pdo));
// Pass this connection to Factory
$qbf = new QueryBuilderFactory($conn);
// Now we can use the factory as QueryBuilder - it creates QueryBuilder
// object every time we use some of method from QueryBuilder and returns it.
$result = $qbf->from('table')->where('cost', '>', 120)->all();
// Set table to operate on.
$qbf->table('table');
$qbf->table('table', 'next-table');
$qbf->table('table', 'next-table', 'and-another');
$qbf->table([ 'table', 'next-table', 'and-another' ]);
// Alias to table() method.
$qbf->from(...);
// Returns passed PDO object.
$qbf->getPdo();
// Returns all Query Segments created in this instance of Query Builder
$qbf->getQuerySegments();
// Or only selected segment
$qbf->getQuerySegment('where');
// Sets and gets EventDispatcher
$qbf->getEventDispatcher();
$qbf->setEventDispatcher(Requtize\QueryBuilder\Event\EventDispatcherInterface $eventDispatcher);
// Sets FetchMode for PDO. IF PDOs Fetch Mode ies all Query Segments, settings to new object and returns new object. Allows to create new Query, but with earlier defined criterias.
$qbf->forkQuery();
$qb->like('column', 'value');
// WHERE column LIKE '%value%'
$qb->like('column', 'value', 'left|start');
// WHERE column LIKE '%value'
$qb->like('column', 'value', 'right|end');
// WHERE column LIKE 'value%'