Pheasant\Finder\Wizard::_sqlFromMethod PHP Method

_sqlFromMethod() private method

Derives an sql clause from a finder method e.g findByLlamaAndBlargh becomes llama=? and blargh=?
private _sqlFromMethod ( $method )
    private function _sqlFromMethod($method)
    {
        if (!preg_match('/^(findBy|oneBy)(.*?)$/', $method, $m)) {
            throw new \BadMethodCallException("Unable to parse {$method}");
        }
        // split on AND or OR and case boundries
        $sql = strtolower(preg_replace('/(?<=[a-z0-9\\b])(Or|And)(?=[A-Z])/', ' $1 ', $m[2]));
        // add parameter binds
        return preg_replace_callback('/\\b([\\w-]+)\\b/', function ($m) {
            return $m[0] != 'or' && $m[0] != 'and' ? "`{$m[0]}`=?" : $m[0];
        }, $sql);
    }