Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Database\Query\Select Class Reference
Inheritance diagram for Hoa\Database\Query\Select:

Public Member Functions

 union ()
 
 unionAll ()
 
 intersect ()
 
 except ()
 
 orderBy ($term)
 
 limit ($expression)
 
 offset ($expression)
 
 __toString ()
 
- Public Member Functions inherited from Hoa\Database\Query\SelectCore
 __construct (Array $columns=[])
 
 distinct ()
 
 all ()
 
 select ($column)
 
 groupBy ($expression)
 
 having ($expression)
 
 from ($source)
 
 _as ($alias)
 
 join ($source)
 
 naturalJoin ($source)
 
 leftJoin ($source)
 
 naturalLeftJoin ($source)
 
 leftOuterJoin ($source)
 
 naturalLeftOuterJoin ($source)
 
 innerJoin ($source)
 
 naturalInnerJoin ($source)
 
 crossJoin ($source)
 
 naturalCrossJoin ($source)
 
 reset ()
 
 __toString ()
 
- Public Member Functions inherited from Hoa\Database\Query\Where
 where ($expression)
 
 __call ($name, Array $values)
 
 __get ($name)
 
 reset ()
 
 __toString ()
 

Protected Member Functions

 compose ($operator)
 
- Protected Member Functions inherited from Hoa\Database\Query\SelectCore
 _join ($type, $source)
 

Protected Attributes

 $_select = []
 
 $_orderBy = []
 
 $_limit = []
 
 $_offset = null
 
- Protected Attributes inherited from Hoa\Database\Query\SelectCore
 $_columns = null
 
 $_distinctOrAll = null
 
 $_from = []
 
 $_groupBy = []
 
 $_having = null
 
- Protected Attributes inherited from Hoa\Database\Query\Where
 $_where = []
 
 $_logicOperator = null
 

Detailed Description

Class .

Build a SELECT query.

Definition at line 47 of file Select.php.

Member Function Documentation

Hoa\Database\Query\Select::__toString ( )

Generate the query.

Returns
string

Implements Hoa\Database\Query\Dml.

Definition at line 183 of file Select.php.

184  {
185  $out = null;
186  $select = implode(' ', $this->_select);
187 
188  if (!empty($select)) {
189  $out .= $select . ' ';
190  }
191 
192  $out .= parent::__toString();
193 
194  if (!empty($this->_orderBy)) {
195  $out .= ' ORDER BY ' . implode(', ', $this->_orderBy);
196  }
197 
198  if (!empty($this->_limit)) {
199  $out .= ' LIMIT';
200 
201  if (null !== $this->_offset) {
202  $out .= ' ' . $this->_limit[0] .
203  ' OFFSET ' . $this->_offset;
204  } else {
205  $out .= ' ' . implode(', ', $this->_limit);
206  }
207  }
208 
209  return $out;
210  }
Hoa\Database\Query\Select::compose (   $operator)
protected

Compose SELECT queries.

Parameters
string$operatorComposition operator.
Returns

Definition at line 125 of file Select.php.

126  {
127  $this->_select[] = parent::__toString() . ' ' . $operator;
128  $this->reset();
129 
130  return $this;
131  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Database\Query\Select::except ( )

Start a new SELECT query which is an exception of the previous one.

Returns

Definition at line 114 of file Select.php.

115  {
116  return $this->compose('EXCEPT');
117  }

Here is the call graph for this function:

Hoa\Database\Query\Select::intersect ( )

Start a new SELECT query which is an intersection of the previous one.

Returns

Definition at line 104 of file Select.php.

105  {
106  return $this->compose('INTERSECT');
107  }

Here is the call graph for this function:

Hoa\Database\Query\Select::limit (   $expression)

Add limit expressions.

Parameters
string$expressionExpression.
......
Returns

Definition at line 156 of file Select.php.

157  {
158  foreach (func_get_args() as $expression) {
159  $this->_limit[] = $expression;
160  }
161 
162  return $this;
163  }
Hoa\Database\Query\Select::offset (   $expression)

Add offset expression.

Parameters
string$expressionExpression.
Returns

Definition at line 171 of file Select.php.

172  {
173  $this->_offset = $expression;
174 
175  return $this;
176  }
Hoa\Database\Query\Select::orderBy (   $term)

Add ordering terms.

Parameters
string$termTerm.
......
Returns

Definition at line 140 of file Select.php.

141  {
142  foreach (func_get_args() as $term) {
143  $this->_orderBy[] = $term;
144  }
145 
146  return $this;
147  }
Hoa\Database\Query\Select::union ( )

Start a new SELECT query which is an union of the previous one.

Returns

Definition at line 84 of file Select.php.

85  {
86  return $this->compose('UNION');
87  }

Here is the call graph for this function:

Hoa\Database\Query\Select::unionAll ( )

Start a new SELECT query which is an unionAll of the previous one.

Returns

Definition at line 94 of file Select.php.

95  {
96  return $this->compose('UNION ALL');
97  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Database\Query\Select::$_limit = []
protected

Definition at line 68 of file Select.php.

Hoa\Database\Query\Select::$_offset = null
protected

Definition at line 75 of file Select.php.

Hoa\Database\Query\Select::$_orderBy = []
protected

Definition at line 61 of file Select.php.

Hoa\Database\Query\Select::$_select = []
protected

Definition at line 54 of file Select.php.


The documentation for this class was generated from the following file: