Cml\Db\Base::parseKey PHP Метод

parseKey() защищенный Метод

SQL语句条件组装
protected parseKey ( string $key, boolean $and = true, boolean $noCondition = false, boolean $noTable = false ) : array
$key string eg: 'forum-fid-1-uid-2'
$and boolean 多个条件之间是否为and true为and false为or
$noCondition boolean 是否为无条件操作 set/delete/update操作的时候 condition为空是正常的不报异常
$noTable boolean 是否可以没有数据表 当delete/update等操作的时候已经执行了table() table为空是正常的
Результат array eg: ['forum', "`fid` = '1' AND `uid` = '2'"]
    protected function parseKey($key, $and = true, $noCondition = false, $noTable = false)
    {
        $condition = '';
        $arr = explode('-', $key);
        $len = count($arr);
        for ($i = 1; $i < $len; $i += 2) {
            isset($arr[$i + 1]) && ($condition .= ($condition ? $and ? ' AND ' : ' OR ' : '') . "`{$arr[$i]}` = %s");
            $this->bindParams[] = $arr[$i + 1];
        }
        $table = strtolower($arr[0]);
        if (empty($table) && !$noTable) {
            throw new \InvalidArgumentException(Lang::get('_DB_PARAM_ERROR_PARSE_KEY_', $key, 'table'));
        }
        if (empty($condition) && !$noCondition) {
            throw new \InvalidArgumentException(Lang::get('_DB_PARAM_ERROR_PARSE_KEY_', $key, 'condition'));
        }
        empty($condition) || ($condition = "({$condition})");
        return [$table, $condition];
    }