Esempio n. 1
0
 /**
  * @param array $values Parameters which were passed to execute(), if any. Default: bound parameters.
  *
  * @return string
  */
 public function getExecutedQueryString(array $values = array())
 {
     $sql = $this->queryString;
     $boundValues = empty($values) ? $this->boundValues : $values;
     $matches = array();
     if (preg_match_all('/(:p[0-9]+\\b)/', $sql, $matches)) {
         $size = count($matches[1]);
         for ($i = $size - 1; $i >= 0; $i--) {
             $pos = $matches[1][$i];
             // trimming extra quotes, making sure value is properly quoted afterwards
             $boundValue = $boundValues[$pos];
             if (is_string($boundValue)) {
                 // quoting only needed for string values
                 $boundValue = trim($boundValue, "'");
                 $boundValue = $this->pdo->quote($boundValue);
             }
             $sql = str_replace($pos, $boundValue, $sql);
         }
     }
     return $sql;
 }