I'm using Cakephp V2.0 and having huge application working on it. Below is the what issue i'm facing right now.
Issue: Select Query is what automatically set condition like "TableName.deleted" != 1
Which does the creating issue actually, i want to add my custom condition in this query to get all soft-deleted records i.e.: "TableName.deleted" == 1 .
but when We are using $this->paginate()
function, it will append default condition at the end of MySQL Query condition and then MySQL Query will look like this:
("TableName.deleted" == 1) AND "TableName.deleted" != 1 Order By xyz
So it's retrieving the record set only by taking last condition and return only records which are not deleted.
How do i remove this default CakePHP condition ("TableName.deleted" != 1)?
Edited(Added Code):
if (isset($this->passedArgs['showdeleted']) && $this->passedArgs['showdeleted'] == 1) {
$displayConditions['AND']['tableName.deleted'] = "1";
} else {
$displayConditions['AND']['tableName.deleted'] = "0";
}
$this->paginate = array(
'conditions' => $displayConditions,
'fields' => $this->displayFields,
'limit' => $show_page,
'group' => 'tableName.id',
'contain' => array(
'tbl1',
'tbl2',
'tbl3',
'tbl4',
'tbl5',
),
);
$returnRecords = $this->paginate();
Can anyone please let me know what should i do to resolve this. any help would be appreciated!
Thanks in advance.