Welcome Guest, Not a member yet? Register   Sign In
db::_delete() ignores $where
#1

[eluser]m4rw3r[/eluser]
I've noticed that db::_delete(), in the db drivers, ignores the $where parameter, and uses $this->ar_where instead.

I use db::_delete() in IgnitedQuery, and I got surprised when I got this query from it: "DELETE FROM `table` WHERE ".
As you can see, it is missing the where part.

In _delete():
Code:
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
    {
    $conditions = '';

    if (count($where) > 0 OR count($like) > 0)
    {
        $conditions = "\nWHERE ";
        $conditions .= implode("\n", $this->ar_where); // here it suddenly ignores $where
...
$where is $this->ar_where when using ActiveRecord, so the bug is only noticed if a 3:rd party lib uses _delete().
#2

[eluser]Colin Williams[/eluser]
The $ar_where property is where all your $this->db->where() and related calls end up. And why would you call _delete() directly? It's obviously meant to be more like a private method.
#3

[eluser]m4rw3r[/eluser]
I call db::_delete() from IgnitedQuery, to generate a db specific query.
(and I'm perfecly aware of how the AR lib works, because I've written a "clone")

But now I've decided to skip the call to db::_delete() because of this problem and the fact that they all are identical, no matter what driver is choosen.

I filed this bug because it is incoherent with the other db specific methods.
(and please do not change them to all use $this->ar_* instead of parameters, because they are reusable by 3:rd party libs if they don't depend on AR being present)




Theme © iAndrew 2016 - Forum software by © MyBB