This is completely optimization question, I have a pagination query like that
$this->paginate = array(
'fields' => array(
'DISTINCT Contact.contact_id',
'Contact.first_name',
'Contact.last_name',
'Contact.email',
'Contact.created',
'ContactGroup.name',
),
'conditions' => array(
$this->conditions,
'ContactsContactGroup.contact_group_id'=>$viewList,
isset($keywordQuery)?$keywordQuery:"",
),
'limit' => 5,
'group' => array('Contact.contact_id')
);
$data = $this->paginate('ContactsContactGroup');
$data = $this->paginate('ContactsContactGroup');
this query is called in every if and else statement, I have four conditions of if
and else
, and in all conditions the above piece of code is written.
I want to optimize, and avoid the big line of code in every condition, how can I optimize it, any answer will be appreciated.