I have a long query like this:
$a=$this->Signin->find('all',
array(
'fields'=> array(
.....
),
'conditions' => array('mytable.user_type ...),
'order' => ....
'limit' => ....
));
user_type column can take values of 0 or 1.
I have a function parameter $type, regarding to this parameter, I need to change my SQL query. Regarding to $type I will query for
- “mytable.user_type”=1,
- “mytable.user_type”=0,
- “mytable.user_type”=1 OR “mytable.user_type=0
I don’t want to write same query three times. I want to change only conditions part. Is it possible?
you can define $type as an array and manage the values in $type
Like for multiple values
for single value
Hence you just need to manipulate $type as per condition, Hope this work