diff --git a/README.md b/README.md index 38fc601..00ebf23 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,10 @@ Observers can also take parameters in their name, much like CodeIgniter's Form V protected function data_process($row) { - $row[$this->callback_parameters[0]] = $this->_process($row[$this->callback_parameters[0]]); + if (is_object($row) && $row->{$this->callback_parameters[0]})//check if object then process + $row->{$this->callback_parameters[0]} = $this->user_model->order_by('level')->get_many($row->{$this->callback_parameters[0]}); + elseif (is_array($row) && $row[$this->callback_parameters[0]])//check if array then process + $row[$this->callback_parameters[0]] = $this->user_model->order_by('level')->get_many($row[$this->callback_parameters[0]]); return $row; } diff --git a/core/MY_Model.php b/core/MY_Model.php index 05add98..6dd8d8c 100644 --- a/core/MY_Model.php +++ b/core/MY_Model.php @@ -135,7 +135,7 @@ public function get_by() if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) { - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); + $this->_database->where($this->_table . '.' . $this->soft_delete_key, (bool)$this->_temporary_only_deleted); } $this->_set_where($where); @@ -184,7 +184,7 @@ public function get_all() if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) { - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); + $this->_database->where($this->_table . '.' . $this->soft_delete_key, (bool)$this->_temporary_only_deleted); } $result = $this->_database->get($this->_table) @@ -454,6 +454,8 @@ public function relate($row) { $relationship = $key; $options = $value; + if (!isset($options['model'])) + $options['model'] = $value . '_model'; } if (in_array($relationship, $this->_with)) @@ -482,6 +484,8 @@ public function relate($row) { $relationship = $key; $options = $value; + if (!isset($options['model'])) + $options['model'] = $value . '_model'; } if (in_array($relationship, $this->_with)) @@ -527,7 +531,7 @@ function dropdown() if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) { - $this->_database->where($this->soft_delete_key, FALSE); + $this->_database->where($this->_table . '.' . $this->soft_delete_key, FALSE); } $result = $this->_database->select(array($key, $value)) @@ -553,7 +557,7 @@ public function count_by() { if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) { - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); + $this->_database->where($this->_table . '.' . $this->soft_delete_key, (bool)$this->_temporary_only_deleted); } $where = func_get_args(); @@ -569,7 +573,7 @@ public function count_all() { if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) { - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); + $this->_database->where($this->_table . '.' . $this->soft_delete_key, (bool)$this->_temporary_only_deleted); } return $this->_database->count_all($this->_table); @@ -702,17 +706,18 @@ public function serialize($row) public function unserialize($row) { - foreach ($this->callback_parameters as $column) - { - if (is_array($row)) - { - $row[$column] = unserialize($row[$column]); - } - else + if ( !empty($row) ) + foreach ($this->callback_parameters as $column) { - $row->$column = unserialize($row->$column); + if (is_array($row)) + { + $row[$column] = unserialize($row[$column]); + } + else + { + $row->$column = unserialize($row->$column); + } } - } return $row; }