From 4d9f23d42fde4b75422f88cf29cdee3af943af78 Mon Sep 17 00:00:00 2001 From: Arif Rana Date: Thu, 11 Dec 2014 18:17:33 +0600 Subject: [PATCH 1/4] doc improve observer method should check if the data is object or array then act accordingly like that --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } From 6a400a8a37a4385a826a626d3718533aced3d4e0 Mon Sep 17 00:00:00 2001 From: Arif Rana Date: Thu, 11 Dec 2014 18:21:58 +0600 Subject: [PATCH 2/4] unserialize method throws warning for empty data fix --- core/MY_Model.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/MY_Model.php b/core/MY_Model.php index 05add98..90a13b7 100644 --- a/core/MY_Model.php +++ b/core/MY_Model.php @@ -702,17 +702,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; } From 724a2aed4fb6ec4cecd6c8e5bbc53f91d512f77a Mon Sep 17 00:00:00 2001 From: Arif Rana Date: Thu, 11 Dec 2014 18:29:00 +0600 Subject: [PATCH 3/4] Undefined index problem fix when user adds primary key for belongs_to & has_many array relationships --- core/MY_Model.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/MY_Model.php b/core/MY_Model.php index 90a13b7..77ddf96 100644 --- a/core/MY_Model.php +++ b/core/MY_Model.php @@ -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)) From a89a235b7283aefe17cfc1687d86e1d2ed7318fe Mon Sep 17 00:00:00 2001 From: Arif Rana Date: Thu, 11 Dec 2014 18:32:39 +0600 Subject: [PATCH 4/4] multiple table join soft_delete_key ambiguous problem fix --- core/MY_Model.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/MY_Model.php b/core/MY_Model.php index 77ddf96..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) @@ -531,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)) @@ -557,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(); @@ -573,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);