/** * Where * * Called by where() or orwhere() * * @access private * @param mixed * @param mixed * @param string * @return object */ function _where($key, $value = NULL, $type = 'AND ', $escape = NULL) { // store this as the last_bracket_type $this->last_bracket_type = 'where'; // call the original method $result = parent::_where($key, $value, $type, $escape); // do we need to add a bracket open if ($this->ar_bracket_open) { // fetch the key of the last entry added end($this->ar_where); $key = key($this->ar_where); // was this the first entry? if ($key == 0) { // first where clause, simply prefix it with a bracket open $this->ar_where[$key] = '(' . $this->ar_where[$key]; } else { // subsequent where clause, strip the type before adding the bracket open $this->ar_where[$key] = $type . ' (' . substr($this->ar_where[$key], strlen($type)); } // reset the bracket state $this->ar_bracket_open = FALSE; // update the AR cache clauses as well if ($this->ar_caching === TRUE) { $this->ar_cache_where[$key] = $this->ar_where[$key]; } } // return the result return $result; }