Doctrine\DBAL\Query\QueryBuilder::from PHP Method

from() public method

$qb = $conn->createQueryBuilder() ->select('u.id') ->from('users', 'u')
public from ( string $from, string | null $alias = null )
$from string The table.
$alias string | null The alias of the table.
    public function from($from, $alias = null)
    {
        return $this->add('from', array('table' => $from, 'alias' => $alias), true);
    }

Usage Example

Esempio n. 1
0
 /**
  * Builds the raw query
  *
  * @return void
  */
 protected function buildQuery()
 {
     $this->queryBuilder = $this->connection->createQueryBuilder();
     $this->queryBuilder->select((array) $this->conf->select);
     /*
      * Main table
      */
     $this->queryBuilder->from($this->conf->from->name, $this->conf->from->alias);
     /*
      * Inner join, right join, left join
      */
     $joinTypes = ['innerJoin', 'leftJoin', 'rightJoin'];
     foreach ($joinTypes as $joinType) {
         if (isset($this->conf->{$joinType})) {
             $joins = $this->conf->{$joinType};
             $this->buildJoins($joinType, $joins);
         }
     }
     /*
      * Condition
      */
     if (isset($this->conf->where)) {
         foreach ($this->conf->where as $where) {
             $this->queryBuilder->andWhere($where);
         }
     }
 }
All Usage Examples Of Doctrine\DBAL\Query\QueryBuilder::from