atk4\data\Persistence_SQL::expr PHP Method

expr() public method

Creates new Expression object from expression.
public expr ( Model $m, string $expr, array $args = [] ) : atk4\dsql\Expression
$m Model
$expr string
$args array
return atk4\dsql\Expression
    public function expr(Model $m, $expr, $args = [])
    {
        preg_replace_callback('/\\[[a-z0-9_]*\\]|{[a-z0-9_]*}/', function ($matches) use(&$args, $m) {
            $identifier = substr($matches[0], 1, -1);
            if ($identifier && !isset($args[$identifier])) {
                $args[$identifier] = $m->getElement($identifier);
            }
            return $matches[0];
        }, $expr);
        return $this->connection->expr($expr, $args);
    }