diff --git a/core/MY_Model.php b/core/MY_Model.php index 369d4ab..fcdf5bd 100644 --- a/core/MY_Model.php +++ b/core/MY_Model.php @@ -387,7 +387,7 @@ public function update_many($primary_values, $data, $skip_validation = FALSE) $result = $this->{$this->_interface} ->where_in($this->primary_key, $this->_prep_primary($primary_values)) ->set($data) - ->update($this->_datasource); + ->update_all($this->_datasource); } // Run registered callbacks @@ -455,7 +455,7 @@ public function update_all($data) { $result = $this->{$this->_interface} ->set($data) - ->update($this->_datasource); + ->update_all($this->_datasource); } // Run registered callbacks @@ -575,7 +575,7 @@ function dropdown() public function count_by() { $where = func_get_args(); - $this->_set_where($where); +// $this->_set_where($where); return $this->_count($where); } @@ -734,7 +734,7 @@ private function _run_before_callbacks($type, $params = array()) { foreach ($this->$name as $method) { - $data = call_user_func_array(array($this, $method), $params); + $data = call_user_func_array(array($this, $method), array($data)); } } @@ -756,7 +756,7 @@ private function _run_after_callbacks($type, $params = array()) { foreach ($this->$name as $method) { - $data = call_user_func_array(array($this, $method), $params); + $data = call_user_func_array(array($this, $method), array($data)); } } @@ -855,7 +855,7 @@ private function _count($all = TRUE) } $count = $this->_mongodb - ? count($this->mongo_db->get($this->_datasource)) + ? $this->mongo_db->count($this->_datasource) : $this->db->$method($this->_datasource); // Restore MongoDB buffered conditions @@ -989,11 +989,15 @@ public function _prep_fields(&$fields, $update = FALSE) foreach ($fields as $key => $value) { // Null-byte injection? - if (!isset($this->_fields[$key])) - { - unset($fields[$key]); + $keys = explode('.', $key); + $tmp = $this->_fields; + foreach ($keys as $key) { + if (!array_key_exists($key, $tmp)) { + unset($fields[reset($keys)]); + break; + } + $tmp = $tmp[$key]; } - // SQL-like injection? // else // {