HABTM relationship

2012-02-23 Thread jholcomb
I am having a problem with an HABTM that has a forth table involved. Here's
the break down

Individuals
AccountsTrailers
AccountsTrailersIndividuals

AccountHolders

AccountsTrailersIndividuals has a field account_holder_id so that I can
associate an individual with an accountstrailer

the error I get is as follows:

Model AccountsTrailersIndividual is not associated with model
AccountHolder

but I have the associations set up properly in the models. They follow for
reference

AccountHolder Model
public $hasMany = array(
'AccountsTrailersIndividual' = array(
'className' = 'AccountsTrailersIndividual',
'foreignKey' = 'account_holder_id',
'dependent' = false,
'conditions' = '',
'fields' = '',
'order' = '',
'limit' = '',
'offset' = '',
'exclusive' = '',
'finderQuery' = '',
'counterQuery' = ''
)
);

AccountsTrailersIndividual Model
public $belongsTo = array(
'Individual' = array(
'className' = 'Individual',
'foreignKey' = 'individual_id',
'conditions' = '',
'fields' = '',
'order' = ''
),
'AccountsTrailer' = array(
'className' = 'AccountsTrailer',
'foreignKey' = 'accounts_trailer_id',
'conditions' = '',
'fields' = '',
'order' = ''
),
'AccountHolder' = array(
'className' = 'AccountHolder',
'foreignKey' = 'account_holder_id',
'conditions' = '',
'fields' = '',
'order' = ''
)
);

What am I missing? Thanks for your help.
Jamie

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/HABTM-relationship-tp5509633p5509633.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


Problems with sessions

2012-01-06 Thread jholcomb
Hello all,

I am trying to add a menu system to my project so that it appears on all my
pages. The one I was able to find that looked good to me is found here,
http://www.palivoda.eu/2008/04/dynamic-menu-in-cakephp/ 

The problem I am running into is after doing everything the site said to do
I get the following error.

Fatal error: Call to a member function read() on a non-object in
C:\UniServer\www\new_company_test\app\View\Layouts\default.ctp on line 41 

line 41 of my default.ctp file is echo
$this-Menu-render($this-Session-read('Menu.main')); 
exactly like the site said to do it.

It looks like this was written in 2008 so I assume this was written for 1.2
or 1.3. 

I have looked at the 2.0 documentation to try and figure out what needs to
change to make it work in 2.0 with no luck.  Is there anyone that can point
me in the right direction to get this resolved? Any help is appreciated.

Thanks
Jamie

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Problems-with-sessions-tp5125948p5125948.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: Problems with sessions

2012-01-06 Thread jholcomb
never mind I figured out my problem.  I needed to add the Session to my
helpers array in my app controller. Found it after reading the manual for
the forth time.

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Problems-with-sessions-tp5125948p5125998.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


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

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+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 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


cakephp find all with several tables

2011-12-15 Thread jholcomb
My problem is I am trying to get data from 5 different tables all the tables
are related and I can create a sql query to get what I want. Here it is.

[code]
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 '^[a-l]'
ORDER BY delinquent_loans.days_delinquent DESC
[/code]

What I don't understand is how to this query in cakePHP the proper way. I'm
sure I can just use the query function and paste the previous query but I
would like to do this the right way. My reading of the cookbook brings me to
trying to use contain, so what I have thus far is this:

[code]
$this-recursive = -1;
return $this-find('all', array(
'contain'=array(
'Loan' = array(
'fields' = array('id', 
'loan_description'),
'AccountsTrailer' = array(
'Account' = array(
'fields' = array('id', 
'account_number'),
'Member' = array(
'fields' = 
array('id', 'first_name'),
'conditions' = 
array(  'first_name regexp \'^[a-l]\'',
),
),
'Balance' = array(
'fields' = array('id', 
'balance'),
),
'Trailer',
),
),
'order' = array('`DelinquentLoan`.`days_delinquent` 
desc'),
'fields' = array('id', 'days_delinquent', 
'amount_delinquent',
'next_contact', 'last_contact'),
)
);
[/code]

I have read the cookbook and formatted this script exactly the way the
cookbook says to do it.  It just doesn't look as though the containable is
working.  The only data I get is from 2 tables DelinquentLoan and Loan. Any
help is appreciated, thank you.

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/cakephp-find-all-with-several-tables-tp5077723p5077723.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: cakephp find all with several tables

2011-12-15 Thread jholcomb
Tried it I think, here is my new code.

[code]
$this-recursive = -1;
return $this-find('all', array(
'contain'=array(
'Loan' = array(
'fields' = array('id', 
'loan_description', 'accounts_trailer_id'),
'AccountsTrailer' = array(
'fields' = array('account_id', 
'trailer_id'),
'Account' = array(
'fields' = array('id', 
'account_number', 'member_id'),
'Member' = array(
'fields' = 
array('id', 'first_name'),
'conditions' = 
array(  'first_name regexp \'^[a-l]\'',
//  
'`Member`.`id` = 
`Account`.`member_id`'

)
),
//  'conditions' = 
array('`Account`.`id` =
`AccountsTrailer`.`account_id`')
),
'Balance' = array(
'fields' = array('id', 
'balance', 'accounts_trailer_id'),
),
'Trailer' = array(
//  'conditions' = 
array('`Trailer`.`id` =
`AccountsTrailer`.`trailer_id`')
),
//  'conditions' = array(  
'`AccountsTrailer`.`id` =
`Loan`.`accounts_trailer_id`',
//  
'`AccountsTrailer`.`id` = 
`Balance`.`accounts_trailer_id`'
//  
)
),
//'conditions' = array('Loan.id = 
DelinquentLoan.loan_id')
),
),
'order' = array('`DelinquentLoan`.`days_delinquent` 
desc'),
'fields' = array('id', 'days_delinquent', 
'amount_delinquent',
'next_contact', 'last_contact'),
)
);
[/code]

perhaps I need to have the conditions uncommented?? Don't know what else to
do at this point, have spent the better part of the last 2 days trying to
figure this out.
Thanks for the help though

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/cakephp-find-all-with-several-tables-tp5077723p5078230.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: cakephp find all with several tables

2011-12-15 Thread jholcomb
Got it here is the final version of the code for those who may want to know.

[code]
$this-recursive = -1;
return $this-find('all', array(
'contain'=array(
'Loan' = array(
'fields' = array('id', 
'loan_description', 'accounts_trailer_id'),
'AccountsTrailer' = array(
'fields' = array('account_id', 
'trailer_id'),
'Account' = array(
'fields' = array('id', 
'account_number', 'member_id'),
'Member' = array(
'fields' = 
array('id', 'first_name'),
'conditions' = 
array(  'first_name regexp \'^[a-l]\'',

)
),
),
'Balance' = array(
'fields' = array('id', 
'balance', 'accounts_trailer_id'),
),
'Trailer' = array(
),
),
),
),
'order' = array('`DelinquentLoan`.`days_delinquent` 
desc'),
'fields' = array('id', 'days_delinquent', 
'amount_delinquent',
'next_contact', 'last_contact', 'loan_id'),
)
);
[/code]

basically adding the foreign keys to all the fields made it work.

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/cakephp-find-all-with-several-tables-tp5077723p5078284.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: cakephp find all with several tables

2011-12-15 Thread jholcomb
my next question has to do with how do I apply pagination to this query?

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/cakephp-find-all-with-several-tables-tp5077723p5078473.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