PHP code example of slam / dbal-debugstack-middleware
1. Go to this page and download the library: Download slam/dbal-debugstack-middleware 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/ */
slam / dbal-debugstack-middleware example snippets
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\ParameterType;
use Slam\DbalDebugstackMiddleware\DebugStack;
use Slam\DbalDebugstackMiddleware\Middleware;
$debugStack = new DebugStack();
$conn = DriverManager::getConnection(
$connectionParams,
(new Configuration)->setMiddlewares([
new Middleware($debugStack)
])
);
$result = $conn->executeQuery(
'SELECT * FROM users WHERE active = :active',
['active' => true],
['active' => ParameterType::BOOLEAN],
);
print_r($debugStack->getQueries());
/*
* Output:
*
Array
(
[0] => Slam\DbalDebugstackMiddleware\Query Object
(
[sql] => SELECT * FROM users WHERE active = :active
[params] => Array
(
[active] => true
)
[types] => Array
(
[active] => 5
)
[executionMs] => 72.05312
)
)
*/