Angejia\Pea\QueryBuilder::isSimple PHP Метод

isSimple() приватный метод

「简单查询」就是只根据主键过滤结果集的查询,有以下两种形式: 1. select * from foo where id = 1; 2. select * from foo where id in (1, 2, 3);
private isSimple ( )
    private function isSimple()
    {
        if ($this->isAwful()) {
            return false;
        }
        if (!$this->wheres) {
            return false;
        }
        if (count($this->wheres) > 1) {
            return false;
        }
        $where = current($this->wheres);
        if ($where['type'] === 'Nested') {
            return false;
        }
        $id = $this->model->primaryKey();
        $tableId = $this->model->table() . '.' . $this->model->primaryKey();
        if (!in_array($where['column'], [$id, $tableId])) {
            return false;
        }
        if ($where['type'] === 'In') {
            return true;
        }
        if ($where['type'] === 'Basic') {
            if ($where['operator'] === '=') {
                return true;
            }
        }
        return false;
    }