Example #1
0
 /**
  * @param string $sSql
  * @param array $aParams
  */
 protected function prepareAndExplain($sSql, $aParams = array())
 {
     $mResult = null;
     if (0 === strpos($sSql, 'SELECT ')) {
         $sSql = 'EXPLAIN ' . $sSql;
         $this->writeLog($sSql);
         $oStmt = $this->getPDO()->prepare($sSql);
         if ($oStmt) {
             foreach ($aParams as $sName => $aValue) {
                 $oStmt->bindValue($sName, $aValue[0], $aValue[1]);
             }
             $mResult = $oStmt->execute() ? $oStmt : null;
         }
     }
     if ($mResult) {
         $aFetch = $mResult->fetchAll(\PDO::FETCH_ASSOC);
         $this->oLogger->WriteDump($aFetch);
         unset($aFetch);
         $mResult->closeCursor();
     }
 }