PHP code example of addiks / doctrine-sql-auto-optimizer

1. Go to this page and download the library: Download addiks/doctrine-sql-auto-optimizer 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/ */

    

addiks / doctrine-sql-auto-optimizer example snippets


$sqlOptimizingEventListener = new \Addiks\DoctrineSqlAutoOptimizer\DoctrineEventListener(
    $logger, # Monolog\Logger                  REQUIRED
    $cache   # Psr\SimpleCache\CacheInterface  OPTIONAL
);

# Doctrine\Common\EventManager
$eventManager->addEventListener(['postConnect'], $sqlOptimizingEventListener);

$schemas = \Addiks\StoredSQL\Schema\SchemasClass::fromPDO(
    $pdo,   # \PDO                            REQUIRED
    $cache, # Psr\SimpleCache\CacheInterface  OPTIONAL
);

$optimizer = new \Addiks\DoctrineSqlAutoOptimizer\DefaultSQLOptimizer(
    $cache   # Psr\SimpleCache\CacheInterface  OPTIONAL
);

$optimizedSql = $optimizer->optimizeSql($inputSql, $schemas);