TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
After count_all declare the where params again.
  • Hey,

    I dont know it is a bug or my misstake. I have a method which will declare where params for an ORM object semi automatically. This works fine and the where statements will be created correctly but I must fire the method in two times. At first before I get the counted rows and than before I will get the result object by limiting with pagination, see below:
    $user = ORM::factory('user');
    $user->setFilterOpExceptions($this->_filterOpException);

    if (!empty($this->_whereParameter)) {
    $user = $user->addFilters($this->_whereParameter);
    }

    $count = $user->count_all();

    if (!empty($this->_whereParameter)) {
    $user = $user->addFilters($this->_whereParameter);
    }


    If I didn't fire:
    if (!empty($this->_whereParameter)) {
    $user = $user->addFilters($this->_whereParameter);
    }
    , the query will be generated without where statement.

    Any ideas to fix them or is this a normal behavior of kohana_orm?