The function constructor comes with predefined methods / functions
FunctionsBuilder / , sum(), count(), concat(), dateDiff(), now() .. , API.
FunctionsBuilder __call SQL, , , "" SQL
$query = $this->SomeTable->find();
$func = $query->func()->substring_index([
'name' => 'identifier',
' ',
-1 => 'literal'
]);
$query->select([, 'surname' => $func]);
, - SQL, , , , , , , , .. , !
, .. name , , `name`, "name" [name] .
( , , '" "'), , , . , / .
SQL :
substring_index((name), :c0, -1)
, ,
substring_index((name), ' ', -1)
-
, ,
, , , , / , integer, datetime, .. , , 'xyz' => 'identifier'.
use Cake\Database\Expression\IdentifierExpression;
substring_index(
[
new IdentifierExpression('title'),
' ',
$value,
],
[
null,
'string',
'integer'
]
)
, , , null.
-
, , , , SUBSTRING_INDEX , , CakePHP, , .
, , , ,
$query->newExpr('SUBSTRING_INDEX(`name`, "", -1)')
-
.