2 :
- , Laravel Query Builder
whereRaw, , . - Laravel (.. Query Builder, PostgresQL), , , .
[1.]:
"Illuminate\Database\Query" :
Laravel 5.0:
:
whereRaw Builder.php():
public function whereRaw($sql, array $bindings = array(), $boolean = 'and')
{
$type = 'raw';
$this->wheres[] = compact('type', 'sql', 'boolean');
$this->addBinding($bindings, 'where');
return $this;
}
compileWheres Grammar.php():
protected function compileWheres(Builder $query)
{
$sql = array();
if (is_null($query->wheres)) return '';
foreach ($query->wheres as $where)
{
$method = "where{$where['type']}";
$sql[] = $where['boolean'].' '.$this->$method($query, $where);
}
if (count($sql) > 0)
{
$sql = implode(' ', $sql);
return 'where '.$this->removeLeadingBoolean($sql);
}
return '';
}
$operator array PostgresGrammar.php():
protected $operators = array(
'=', '<', '>', '<=', '>=', '<>', '!=',
'like', 'not like', 'between', 'ilike',
'&', '|', '#', '<<', '>>',
);
, ? ; -)
, PostgreSQL PostgresGrammar.php():
protected function compileUpdateWheres(Builder $query)
{
$baseWhere = $this->compileWheres($query);
if ( ! isset($query->joins)) return $baseWhere;
$joinWhere = $this->compileUpdateJoinWheres($query);
if (trim($baseWhere) == '')
{
return 'where '.$this->removeLeadingBoolean($joinWhere);
}
return $baseWhere.' '.$joinWhere;
}
protected function compileUpdateJoinWheres(Builder $query)
{
$joinWheres = array();
foreach ($query->joins as $join)
{
foreach ($join->clauses as $clause)
{
$joinWheres[] = $this->compileJoinConstraint($clause);
}
}
return implode(' ', $joinWheres);
}
compileWheres, , , ( 2!!!) (Illuminate\Database\Query\Grammars\Grammar).
(SOFTonSOFA).
:
, : Laravel - , , , ..). .
, Buar Builder Builder PostgreSQL, ? whereRaw.
, /, .