Thursday, May 24, 2012

Re: Model Associations

Yes.

As a disclaimer, I didn't write the original schema.

Account_ID is for the systems account number (primary key)
Account is for the logical account number (used by the company)

The Account Address table use the Account_ID as the foreign key, but the Contact Table uses the Account Number as the foreign key.

SQLDUMP:

SELECT [CONTACT_FULL_NAME] AS [Contact__CONTACT_FULL_NAME], [Contact].[CONTACT_FIRST_NAME] AS [Contact__CONTACT_FIRST_NAME] FROM [CONTACTS] AS [Contact] WHERE [Contact].[Account_ID] = [Accounts].[Account] 


error:

Error: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "Accounts.Account" could not be bound.


On Thu, May 24, 2012 at 3:28 AM, Mike Griffin <griffinm@gmail.com> wrote:
On Thu, May 24, 2012 at 1:50 AM, hill180 <hill180@gmail.com> wrote:
> AccountID = AccountID on the Account and the Address for the Account, no
> problems here.
>
>
> The problem is the contacts.
>
> The join is Contact.Account_id = Accounts.Account (not Account_ID)
>
> Error: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 11.0][SQL
> Server]The multi-part identifier "Accounts.Account" could not be bound.
>

Are you saying that the Accounts.Account and Accounts.AccountID are
different fields and have different values?

What's the actual SQL statement that is being created and causes the error?

Mike.

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

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

No comments: