Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about where(null) #770

Closed
jinmarcus opened this issue Oct 12, 2017 · 4 comments
Closed

about where(null) #770

jinmarcus opened this issue Oct 12, 2017 · 4 comments

Comments

@jinmarcus
Copy link

The null parameter cannot be passed in the where method
Like this

$db->table('test')->where(null)->get()->getRow();

Run error reporting

@JakeAi
Copy link
Contributor

JakeAi commented Oct 12, 2017

@jinmarcus Why do you need to do this? Where looks to see if the $key is an array. If it is not an array, then the first param is the key value, second param is the value for that key. Otherwise the first param is an array with key => value pair... This is what is required/supported.

where(["id" => null]);
where("id", null);

@jinmarcus
Copy link
Author

jinmarcus commented Oct 13, 2017

Ci3 can be, I have been accustomed to write, because you can write functions, $where can be as a parameter by value, if there is no $where you can pass null, now to determine $where exists, is not very convenient

CI3 like this

public function getSort($db, $where = null, $order = 'id desc') {
        return $this->db->select('sort')->order_by($order)->where($where)->get()->result();
}

but now, CI4 like this

public function getSort($db, $where = null, $order = 'id desc') {
        $this->db->table($db)->select('sort')->orderBy($order);

        if ($where !== null) {
            $this->db->where($where);
        }

        return $this->db->get()->getResult();
}

This way, it doesn't get smooth!
and getWhere(null) is ok ,why where(null) not?

@lonnieezell
Copy link
Member

Hm. I didn't think we changed anything in those query builder methods. I would accept a PR for this, though.

@jinmarcus
Copy link
Author

#792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants