1. Go to this page and download the library: Download blrf/dbal 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/ */
blrf / dbal example snippets
ig = new Blrf\Dbal\Config('mysql://user:pass@localhost/bookstore');
$config->create()->then(
function (Blrf\Dbal\Connection $db) {
// start query builder
$qb = $db->query()
->select('*')
->from('book')
->where(
fn(Blrf\Dbal\Query\ConditionBuilder $cb) => $cb->or(
$cb->and(
$cb->eq('isbn13'),
$cb->eq('language_id'),
),
$cb->eq('title')
)
)
->setParameters(['9789998691568', 1, 'Moby Dick'])
->limit(3);
// $qb->getSql(): SELECT * FROM book WHERE ((isbn13 = ? AND language_id = ?) OR title = ?) LIMIT 3
return $qb->execute();
}
)->then(
function (Blrf\Dbal\Result $result) {
print_r($result->rows);
}
);
$config = new Blrf\Dbal\Config('mysql://user:pass@localhost/bookstore');
$config->create()->then(
function (Blrf\Dbal\Connection $db) {
// start query builder
$qb = $db->query()
->select('*')
->from('book')
->where(
fn(Blrf\Dbal\Query\ConditionBuilder $cb) => $cb->or(
$cb->and(
$cb->eq('isbn13'),
$cb->eq('language_id'),
),
$cb->eq('title')
)
)
->setParameters(['9789998691568', 1, 'Moby Dick'])
->limit(3);
// sql: SELECT * FROM book WHERE ((isbn13 = ? AND language_id = ?) OR title = ?) LIMIT 3
$stream = $qb->stream();
$stream->on('data', function (array $row) {
echo " - received row: \n";
print_r($row);
});
$stream->on('error', function (\Throwable $e) {
echo " ! error: " . $e->getMessage() . "\n";
});
$stream->on('close', function () {
echo " - Stream done\n";
});
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.