45
* Clausula WHERE con AND
47
* @param string $conditions condiciones AND
47
* @param string | array $conditions condiciones
50
50
public function where($conditions)
52
$this->_sql['where'][] = $this->_where($conditions);
57
* Clausula WHERE con OR
59
* @param string $conditions condiciones OR
62
public function whereOr($conditions)
64
$this->_sql['where'][] = $this->_where($conditions, FALSE);
69
* Método interno para crear la Clusula WHERE
71
* @param string $conditions
72
* @param bool $type TRUE = AND; FALSE = OR
73
* @return string clausula
75
protected function _where($conditions, $type=TRUE)
78
if(isset($this->_sql['where'])){
53
if(is_array($conditions)){
54
foreach ($conditions as $k => $v) {
55
$this->_sql['params'][] = $v;
85
return $cond . "($conditions)";
88
* Parámetros que seran enlazados a la setencia SQL
93
public function bind($bind)
95
foreach ($bind as $k => $v) {
96
$this->_sql['bind'][":$k"] = $v;
102
* Parámetro que sera enlazado a la setencia SQL
104
* @param string $bind
105
* @param string $value
108
public function bindValue($bind, $value)
110
$this->_sql['bind'][":$bind"] = $value;
115
* Retorna los elementos para ser enlazados
119
public function getBind()
121
if(isset($this->_sql['bind'])){
122
return $this->_sql['bind'];
59
$this->_sql['where'] = $where;
63
* Parametros que seran enlazados a la setencia SQL
67
public function params()
69
if(isset($this->_sql['params'])){
70
return $this->_sql['params'];
130
78
* @param string $table nombre de tabla
131
79
* @param string $conditions condiciones
134
82
public function join($table, $conditions)
136
84
$this->_sql['join'][] = array('table' => $table, 'conditions' => $conditions);
143
91
* @param string $table nombre de tabla
144
92
* @param string $conditions condiciones
147
95
public function leftJoin($table, $conditions)
149
97
$this->_sql['leftJoin'][] = array('table' => $table, 'conditions' => $conditions);
156
104
* @param string $table nombre de tabla
157
105
* @param string $conditions condiciones
158
106
* @return DbQuery
160
108
public function rightJoin($table, $conditions)
162
110
$this->_sql['rightJoin'][] = array('table' => $table, 'conditions' => $conditions);
169
117
* @param string $table nombre de tabla
170
118
* @param string $conditions condiciones
171
119
* @return DbQuery
173
121
public function fullJoin($table, $conditions)
175
123
$this->_sql['fullJoin'][] = array('table' => $table, 'conditions' => $conditions);
266
214
* @param string $columns columnas
267
215
* @return DbQuery
269
public function select($columns = NULL)
217
public function select($columns='*')
271
$this->_sql['command'] = 'select';
274
$this->columns($columns);
219
$this->_sql['select'] = $columns;
280
223
* Columnas a utilizar en el Query
282
* @param string $columns columnas
283
224
* @return DbQuery
285
226
public function columns($columns)
287
$this->_sql['columns'] = $columns;
228
$this->select($columns);
292
232
* Construye la consulta DELETE
294
234
* @return DbQuery
296
236
public function delete()
298
$this->_sql['command'] = 'delete';
303
* Construye la consulta UPDATE
305
* @param array $data claves/valores
308
public function update($data)
311
$this->_sql['data'] = $data;
312
$this->_sql['command'] = 'update';
317
* Construye la consulta UPDATE
319
* @param string | array $data columnas, o array de claves/valores
322
public function insert($data)
325
$this->_sql['data'] = $data;
326
$this->_sql['command'] = 'insert';
238
$this->_sql['delete'] = TRUE;
243
* Construye la consulta UPDATE
245
* @param string | array $values claves/valores
248
public function update($values)
250
$this->_sql['update'] = $values;
255
* Construye la consulta UPDATE
257
* @param string | array $columns columnas, o array de claves/valores
258
* @param string $values
261
public function insert($columns, $values=null)
263
$this->_sql['insert'] = array('columns' => $columns, 'values' => $values);