Kdyby\Doctrine\EntityManager::createQueryBuilder PHP Method

createQueryBuilder() public method

public createQueryBuilder ( $alias = NULL, $indexBy = NULL ) : Kdyby\Doctrine\QueryBuilder
return Kdyby\Doctrine\QueryBuilder
    public function createQueryBuilder($alias = NULL, $indexBy = NULL)
    {
        if ($alias !== NULL || $indexBy !== NULL) {
            throw new NotSupportedException('Use EntityRepository for $alias and $indexBy arguments to work.');
        }
        if (($config = $this->getConfiguration()) instanceof Configuration) {
            $class = $config->getQueryBuilderClassName();
            return new $class($this);
        }
        return new QueryBuilder($this);
    }

Usage Example

 /**
  * @param string|null
  * @param string|null
  * @param string|null
  * @return QueryBuilder
  */
 public function createQueryBuilder($entityClass = NULL, $alias = NULL, $indexBy = NULL)
 {
     $qb = $this->entityManager->createQueryBuilder();
     if ($entityClass) {
         $qb->from($entityClass, $alias, $indexBy);
         $qb->select($alias);
     }
     return $qb;
 }
All Usage Examples Of Kdyby\Doctrine\EntityManager::createQueryBuilder