PHP code example of shipmonk / doctrine-hint-driven-sql-walker
1. Go to this page and download the library: Download shipmonk/doctrine-hint-driven-sql-walker 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/ */
shipmonk / doctrine-hint-driven-sql-walker example snippets
$queryBuilder
->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, HintDrivenSqlWalker::class)
->setHint(MaxExecutionTimeHintHandler::class, 1000)
class MaxExecutionTimeSqlWalker extends HintHandler
{
public function getNodes(): array
{
return [SqlNode::SelectClause];
}
public function processNode(
SqlNode $sqlNode,
string $sql,
): string
{
// grab the 1000 passed to ->setHint()
$milliseconds = $this->getHintValue();
// edit SQL as needed
return preg_replace(
'~^SELECT (.*?)~',
"SELECT /*+ MAX_EXECUTION_TIME($milliseconds) */ \\1 ",
$sql
);
}