This is completely optimization question, I have a pagination query like this:
$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
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.