Skip to content

Commit 7814bcf

Browse files
committed
Duplicate WHERE clause with softdelete
Prevent duplicate WHERE clause when soft delete is use. When chaining the where method instead of passing the where as an argument to the read method, it creates a duplicate where clause for the deleted_at field.
1 parent 15980db commit 7814bcf

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Diff for: core/MY_Model.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,6 @@ public function update($data = NULL, $column_name_where = NULL, $escape = TRUE)
612612
*/
613613
public function where($field_or_array = NULL, $operator_or_value = NULL, $value = NULL, $with_or = FALSE, $with_not = FALSE, $custom_string = FALSE)
614614
{
615-
if($this->soft_deletes===TRUE)
616-
{
617-
$backtrace = debug_backtrace(); #fix for lower PHP 5.4 version
618-
if($backtrace[1]['function']!='force_delete'){
619-
$this->_where_trashed();
620-
}
621-
}
622-
623615
if(is_array($field_or_array))
624616
{
625617
$multi = $this->is_multidimensional($field_or_array);
@@ -936,7 +928,7 @@ public function get($where = NULL)
936928
{
937929
$this->where($where);
938930
}
939-
elseif($this->soft_deletes===TRUE)
931+
if($this->soft_deletes===TRUE)
940932
{
941933
$this->_where_trashed();
942934
}
@@ -984,7 +976,7 @@ public function get_all($where = NULL)
984976
{
985977
$this->where($where);
986978
}
987-
elseif($this->soft_deletes===TRUE)
979+
if($this->soft_deletes===TRUE)
988980
{
989981
$this->_where_trashed();
990982
}
@@ -1035,7 +1027,7 @@ public function count_rows($where = NULL)
10351027
{
10361028
$this->where($where);
10371029
}
1038-
elseif($this->soft_deletes===TRUE)
1030+
if($this->soft_deletes===TRUE)
10391031
{
10401032
$this->_where_trashed();
10411033
}

0 commit comments

Comments
 (0)