Re: Paginator not working on custom query

2011-12-16 Thread jholcomb
the paginate function is in my model

this is what is in my controller
$delinquentLoans = $this->DelinquentLoan->paginate('m-z');
$this->set('delinquentLoans', $delinquentLoans);

mysql is the database server.

Do I have to do something like 

var $helpers = array('paginator');

in my controller?

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Paginator-not-working-on-custom-query-tp5080932p5081310.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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Paginator not working on custom query

2011-12-16 Thread Geoff Douglas
Are you calling the paginate method from the controller?

You are getting this error because the Paginator Helper doesn't have 
anything to use.

What database server are you running?

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Paginator not working on custom query

2011-12-16 Thread jholcomb
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

Paginator->sort('name');?>

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php