Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Table was used using associations but the association has a typo with belongsTo #8161

Closed
LeLuyen opened this issue Feb 2, 2016 · 1 comment
Milestone

Comments

@LeLuyen
Copy link

LeLuyen commented Feb 2, 2016

Dear All,

I have an error about TranslateBehavior with belongsTo relation.
Here is my bug

Error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous

If you are using SQL keywords as table column names, you can enable identifier quoting for your database connection in config/app.php.

SQL Query:

SELECT Terms.name AS Terms__name, Terms_name_translation.id AS Terms_name_translation__id, Terms_name_translation.content AS Terms_name_translation__content FROM terms Terms LEFT JOIN terms_i18n Terms_name_translation ON (Terms_name_translation.model = :c0 AND Terms_name_translation.field = :c1 AND Terms_name_translation.locale = :c2 AND Terms.id = (Terms_name_translation.foreign_key)) LEFT JOIN terms_i18n Terms_description_translation ON (Terms_description_translation.model = :c3 AND Terms_description_translation.field = :c4 AND Terms_description_translation.locale = :c5 AND Terms.id = (Terms_description_translation.foreign_key)) WHERE id in (:c6)
Could this be caused by using Auto-Tables?

Some of the Table objects in your application were created by instantiating "Cake\ORM\Table" instead of any other specific subclass.

This could be the cause for this exception. Auto-Tables are created for you under the following circumstances:

The class for the specified table does not exist.
The Table was created with a typo: TableRegistry::get('Atricles');
The class file has a typo in the name or incorrect namespace: class Atricles extends Table
The file containing the class has a typo or incorrect casing: Atricles.php
The Table was used using associations but the association has a typo: $this->belongsTo('Atricles')
The table class resides in a Plugin but no plugin notation was used in the association definition.

Please try correcting the issue for the following table aliases:

TermsI18n
Terms_name_translation
Terms_description_translation

Please help me!

Thanks you!

@LeLuyen LeLuyen changed the title The Table was used using associations but the association has a typo width belongsTo The Table was used using associations but the association has a typo with belongsTo Feb 2, 2016
@markstory markstory added this to the 3.2.2 milestone Feb 2, 2016
@markstory
Copy link
Member

Your where clause is ambiguous. You'll need to fix your query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants