Tuesday, March 26, 2013

Custom find paginate only shows 1 page result.

I have the following custom find function definition which is working correctly executing SQL query and returns correct values, but it isn't returning any page number correctly to paginate helper

public function _findgeneral($state, $query, $results = array()){
if($state=='before'){
if(isset($query['_modo']) && isset($query['_parametros'])){
switch($query['_modo']){
case '1':
$condiciones['Order.client_id'] = $query['_parametros'];
break;
case '2':
$condiciones['Order.control'] = $query['_parametros'];
break;
case '3':
$condiciones['Order.status'] = $query['_parametros'];
break;
default:
throw new NotFoundException(__('Tipo de búsqueda no definido.'));
break;
}
}elseif(isset($query['_status'])){
if((int)$query['_status'] > 0 && (int)$query['_status'] <= 4){
$condiciones['Order.status'] = $query['_status'];
}
else{
throw new NotFoundException(__('Error en el parámetro $status'));
}
}
$condiciones['Order.inactive'] = '0';
$query['conditions'] = $condiciones;
$query['fields'] = array(
'Order.id',
'Order.control',
'Order.commentary',
'Order.created',
'Order.modified',
'Order.status'
);
$query['contain'] =  array(
'Client' => array(
'fields' => array(
'Client.name',
'Client.id'
)
),
'Vendor' => array(
'fields' => array(
'Vendor.name',
'Vendor.id'
)
)
);
$query['limit'] = '2';
return $query;
}
if($state=='after'){
return $results;
}
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: