builder() публичный Метод

Get current Doctrine DBAL query builder object
public builder ( ) : Doctrine\DBAL\Query\QueryBuilder
Результат Doctrine\DBAL\Query\QueryBuilder
Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function read(Query $query)
 {
     $builder = $query->builder();
     $queryHash = md5($builder->getSql() . '_' . serialize($builder->getParameters()));
     if ($this->mapper instanceof MapperCacheInterface) {
         if ($builder->getType() == 0) {
             $collection = $this->mapper->getQueryFromCache($queryHash);
             if ($collection) {
                 return $collection;
             }
         } else {
             $this->mapper->clearQueryCache();
         }
     }
     /*
     if ($query->builder()->getType() == 0) {
         $clonedQuery = clone $query->builder();
     
         $res = $clonedQuery->getConnection()->executeQuery('EXPLAIN ' . $clonedQuery->getSQL(), $clonedQuery->getParameters(), $clonedQuery->getParameterTypes());
         $res->setFetchMode(\PDO::FETCH_ASSOC);
     
         echo '<pre>';
         var_dump($queryHash);
         var_dump($clonedQuery->getSQL());
         var_dump($clonedQuery->getParameters());
         var_dump($res->fetchAll());
         echo '</pre>';
     }
     */
     $stmt = $builder->execute();
     $stmt->setFetchMode(\PDO::FETCH_ASSOC);
     $collection = $query->mapper()->collection($stmt, $query->with());
     $stmt->closeCursor();
     if ($this->mapper instanceof MapperCacheInterface && $builder->getType() == 0) {
         $this->mapper->addQueryToCache($queryHash, $collection);
     }
     return $collection;
 }
Пример #2
0
 /**
  * Execute provided query and return result
  *
  * @param  \Spot\Query $query SQL query to execute
  * @return \Doctrine\DBAL\Driver\Statement|int
  * @throws \Spot\Exception
  */
 public function exec(Query $query)
 {
     return $query->builder()->execute();
 }