Elgg  Version master
SelectClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
5 use Doctrine\DBAL\Query\Expression\CompositeExpression;
7 
11 class SelectClause extends Clause {
12 
16  public $expr;
17 
23  public function __construct($expr) {
24  $this->expr = $expr;
25  }
26 
30  public function prepare(QueryBuilder $qb, $table_alias = null) {
31  $select = $this->expr;
32 
33  if ($this->isCallable($select)) {
34  $select = $this->call($this->expr, $qb, $table_alias);
35  }
36 
37  if ($select instanceof CompositeExpression || is_string($select)) {
38  $qb->addSelect($select);
39  }
40  }
41 }
Interface that allows resolving statements and/or extending query builder.
Definition: Clause.php:14
isCallable($callback)
Check if a clause expression is callable.
Definition: Clause.php:35
call($callback, QueryBuilder $qb, $table_alias=null)
Call the expression for the clause.
Definition: Clause.php:48
Extends QueryBuilder with SELECT clauses.
prepare(QueryBuilder $qb, $table_alias=null)
{Build an expression and/or apply it to an instance of query builder.Query builder Table aliasComposi...
Database abstraction query builder.
$qb
Definition: queue.php:12