Beispiel #1
0
 /**
  * @param string $query
  * @param array $parameters
  */
 protected function prepare(&$query, array &$parameters = array())
 {
     $binds = array();
     $sprintfArgs = array();
     foreach ($parameters as $key => $value) {
         if ($value instanceof \Berthe\DAL\ComplexType) {
             list($subQuery, $params) = $value->toDbRepresentation();
             $args = array();
             foreach ($params as $paramKey => $paramValue) {
                 $paramName = $key . '_' . $paramKey;
                 $args[] = ':' . $paramName;
                 $binds[':' . $paramName] = $paramValue;
             }
             $sprintfArgs[] = vsprintf($subQuery, $args);
         } else {
             $sprintfArgs[] = ':' . $key;
             $binds[':' . $key] = $value;
         }
     }
     if (empty($parameters) || isset($parameters[0])) {
         $binds = $parameters;
     } else {
         $query = vsprintf($query, $sprintfArgs);
     }
     $parameters = $this->parametersTransformer->transform($binds);
 }
 /**
  *
  * @param string $query
  * @param array  $parameters
  * @param int    $fetchMode
  *
  * @return array
  */
 public function fetchRow($query, array $parameters = array(), $fetchMode = null)
 {
     $parameters = $this->parameterTransformer->transform($parameters);
     $this->stopWatch->start('query', 'database');
     $result = $this->reader->fetchRow($query, $parameters, $fetchMode);
     $event = $this->stopWatch->stop('query');
     $this->log($query, $parameters, $event, 'fetch', 'row');
     return $result;
 }
Beispiel #3
0
 /**
  *
  * @param string $query
  * @param array  $parameters
  * @param int    $fetchMode
  *
  * @return array
  */
 public function fetchRow($query, array $parameters = array(), $fetchMode = null)
 {
     $parameters = $this->parameterTransformer->transform($parameters);
     return $this->db->fetchRow($query, $parameters, $fetchMode);
 }