Friday, December 16, 2011

Paginator not working on custom query

I am trying to get my custom query to paginate. Reading through the book and
searching has not been all that helpful to me. A few places have said to
put a function paginate in the model which I have done. The 2 functions that
I understand to need follow.

public function paginate($conditions = null, $fields = null, $order = null,
$limit = 25, $page = 1, $recursive = -1, $extra = null){
return $this->query("SELECT accounts.account_number, trailers.id,
members.first_name, balances.balance, loans.loan_description,
delinquent_loans.days_delinquent, delinquent_loans.amount_delinquent,
delinquent_loans.next_contact, delinquent_loans.last_contact
FROM accounts, trailers, members, balances, accounts_trailers, loans,
delinquent_loans
WHERE delinquent_loans.loan_id = loans.id
AND loans.accounts_trailer_id = accounts_trailers.id
AND accounts_trailers.account_id = accounts.id
AND accounts_trailers.trailer_id = trailers.id
AND accounts.member_id = members.id
AND balances.accounts_trailer_id = accounts_trailers.id
AND members.first_name
REGEXP '^[".$conditions."]'
ORDER BY delinquent_loans.days_delinquent DESC");
}

public function paginateCount($conditions = null, $recursive = -1, $extra =
null) {
return $this->query("Select count(*) from accounts, trailers, members,
balances, accounts_trailers, loans, delinquent_loans
WHERE delinquent_loans.loan_id = loans.id
AND loans.accounts_trailer_id = accounts_trailers.id
AND accounts_trailers.account_id = accounts.id
AND accounts_trailers.trailer_id = trailers.id
AND accounts.member_id = members.id
AND balances.accounts_trailer_id = accounts_trailers.id
AND members.first_name
REGEXP '^[".$conditions."]'
ORDER BY delinquent_loans.days_delinquent DESC");
}

Unfortunately, all this does is yield the following error.

Fatal error: Call to a member function sort() on a non-object in
C:\UniServer\www\new_company_test\app\View\DelinquentLoans\mthruz.ctp on
line 10

this is line 10 of that file

<th><?php echo $this->Paginator->sort('name');?></th>

Any help here is appreciated as the documentation I have found does not go
into detail when wanting to use the query function.

--
View this message in context: http://cakephp.1045679.n5.nabble.com/Paginator-not-working-on-custom-query-tp5080932p5080932.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate