True, but I was just trying to do a findCount..., then modify the
$limit and $page params and allow the findAll to proceed and return the
bounded dataset.
I've seen the component approach, but I'm just not conviced that there
needs to be anything outside of the Model on this - if the Model (when
told to do) simply serves the requested data back in a decorated way -
it's seamless. Then a view helper can be passed the result and render
the datagrid & paginate.
I accomplished for Model::find already by doing the following:
function query($sql){
if ($this->_datagrid){
$return_data = array();
// First Get Record count of unbounded query
$query_info = parent::query('EXPLAIN ('.$sql.')');
$total_records = $query_info[0][0]['rows'];
$return_data['pagination']['num_records'] =
$total_records;
$return_data['pagination']['num_pages'] =
(int)floor($total_records
/ $this->num_rows);
$return_data['pagination']['current_page'] =
$this->current_page;
// Now bound the query and get the dataset
$record_offset = $this->findRecordOffset();
$sql .= ' LIMIT '.$record_offset.','.$this->num_rows;
$return_data['rows'] = parent::query($sql);
return $return_data;
} else {
return parent::query($sql);
}
}
This can done for findAll as well if I could just get the unbounded
count. I have a hacked version that grabs the whole dataset and
returns only the rows for the given page - but NOT fetching the whole
dataset is the reason for pagination in the first place :)
If anyone has any thoughts hit me up - I'd love to get this posted to
cakeforge!
Best,
B.
On Oct 16, 11:59 am, "AD7six" <[EMAIL PROTECTED]> wrote:
> If you call a method that triggers a find in your beforeFind method you
> created a loop ;).
>
> If you goal is just pagination have you seen
> this:http://bakery.cakephp.org/articles/view/65
>
> Also, cake 1.2 will have native pagination support.
>
> HTH,
>
> AD7six
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---