1. Go to this page and download the library: Download arekx/pql 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/ */
arekx / pql example snippets
use function \ArekX\PQL\Sql\{select, all, equal, column, value};
// ... driver and builder initialization left out for brevity.
/** @var \ArekX\PQL\Contracts\Driver $driver */
/** @var \ArekX\PQL\Contracts\QueryBuilder $builder */
$runner = QueryRunner::create($driver, $builder);
// Fetching all results
$query = select('*') // or Select::create()->columns('*') if you do not want to use functions.
->from('user')
->where(all(['is_active' => 1]));
// Built query equals to: SELECT * FROM `user` WHERE `is_active` = 1;
$runner->fetchAll($query); // Returns all data for user table
// Complex select query:
$query = select('*')
->from(['u' => 'user'])
->innerJoin(['r' => 'user_role'], 'u.role_id = r.id')
->where(['all', [
'u.is_active' => 1,
'r.id' => select('role_id')
->from('application_roles')
->where(equal(column('application_id'), value(2)))
]);
/*
Built query equals to:
SELECT
*
FROM `user` AS `u`
INNER JOIN `user_role` AS `r` ON u.role_id = r.id
WHERE
`u`.`is_active` = 1
AND `r`.`id` IN (
SELECT `role_id` FROM `application_roles` WHERE `application_id` = 2
)
*/
$runner->fetchAll($query); // Returns all data for this query
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.