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

Public Member Functions

 where ($expression)
 
 __call ($name, Array $values)
 
 __get ($name)
 
 reset ()
 
 __toString ()
 

Protected Attributes

 $_where = []
 
 $_logicOperator = null
 

Detailed Description

Class .

Build a WHERE clause.

Definition at line 47 of file Where.php.

Member Function Documentation

Hoa\Database\Query\Where::__call (   $name,
Array  $values 
)

Redirect undefined calls to _calls.

Parameters
string$nameName.
array$valuesValues.
Returns

Definition at line 96 of file Where.php.

97  {
98  return call_user_func_array([$this, '_' . $name], $values);
99  }
Hoa\Database\Query\Where::__get (   $name)

Set the current logic operator.

Parameters
string$nameName.
Returns

Definition at line 107 of file Where.php.

108  {
109  switch (strtolower($name)) {
110  case 'and':
111  case 'or':
112  $this->_logicOperator = strtoupper($name);
113 
114  break;
115 
116  default:
117  return $this->$name;
118  }
119 
120  return $this;
121  }
Hoa\Database\Query\Where::__toString ( )

Generate the query.

Returns
string

Definition at line 140 of file Where.php.

141  {
142  if (empty($this->_where)) {
143  return null;
144  }
145 
146  return ' WHERE ' . implode(' ', $this->_where);
147  }
Hoa\Database\Query\Where::reset ( )

Reset.

Returns

Definition at line 128 of file Where.php.

129  {
130  $this->_where = [];
131 
132  return $this;
133  }
Hoa\Database\Query\Where::where (   $expression)

Add an expression (regular string or a WHERE clause).

Parameters
mixed$expressionExpression.
Returns

Definition at line 71 of file Where.php.

72  {
73  $where = null;
74 
75  if (!empty($this->_where)) {
76  $where = ($this->_logicOperator ?: 'AND') . ' ';
77  }
78 
79  if ($expression instanceof self) {
80  $expression = '(' . substr($expression, 7) . ')';
81  }
82 
83  $this->_where[] = $where . $expression;
84  $this->_logicOperator = null;
85 
86  return $this;
87  }

Member Data Documentation

Hoa\Database\Query\Where::$_logicOperator = null
protected

Definition at line 61 of file Where.php.

Hoa\Database\Query\Where::$_where = []
protected

Definition at line 54 of file Where.php.


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