Do you need some ids in arrays keys to complete the join (to Contact.id) - 
perhaps Project.contact_id?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 31 Oct 2011, at 18:48, zuha wrote:

> I've posted about this before, but previously it was because AppModel wasn't 
> getting loaded (I have made sure that it and containable is being loaded this 
> time).  But even though they are being loaded, I'm again having a problem 
> where 'contain' stops working.   I go to the beforeFind method and print out 
> the $queryData, and sure enough contain is in the array, and I get this sql 
> error because there is no join in the sql on the contact table. 
> 
> Column not found: 1054 Unknown column 'Contact.name' in 'field list' 
> 
> With this Query ::  SELECT `Project`.`id`, (CONCAT(`Project`.`name`, " ", 
> `Contact`.`name`, "")) AS `Project__displayName` FROM `projects` AS `Project` 
> INNER JOIN `used` AS `Used` ON (`Used`.`foreign_key` = `Project`.`id` AND 
> `Used`.`model` = 'Project' AND `Used`.`user_id` = 1) WHERE 1 = 1 ORDER BY 
> `Project`.`name` ASC 
> 
> Mind you this query works in every other place in our app because the Contact 
> table is automatically joined with containable.  Just in this one plugin it 
> seems to be impossible to get contain to work when its called from this 
> plugin to another plugin.
> 
> Here is the line that is creating this query in TimesheetsController.php : 
> $projects = $this->TimesheetTime->Project->find('list');
> 
> Here is the output from beforeFind($queryData) { debug($queryData) } in the 
> Project model  (most notably is that 'contain' => Contact.name exists in the 
> queryData)
> 
> Array
> (
>     [conditions] => 
>     [fields] => Array
>         (
>             [0] => Project.id
>             [1] => Project.displayName
>         )
> 
>     [joins] => Array
>         (
>             [0] => Array
>                 (
>                     [table] => used
>                     [alias] => Used
>                     [type] => INNER
>                     [conditions] => Array
>                         (
>                             [0] => Used.foreign_key = Project.id
>                             [1] => Used.model = 'Project'
>                             [2] => Used.user_id = 1
>                         )
> 
>                 )
> 
>         )
> 
>     [limit] => 
>     [offset] => 
>     [order] => Array
>         (
>             [0] => Array
>                 (
>                     [0] => Project.name
>                 )
> 
>         )
> 
>     [page] => 1
>     [group] => 
>     [callbacks] => 1
>     [contain] => Array
>         (
>             [0] => Contact.name
>         )
> 
>     [recursive] => -1
>     [list] => Array
>         (
>             [groupPath] => 
>             [valuePath] => {n}.Project.displayName
>             [keyPath] => {n}.Project.id
>         )
> 
> )
> 
> 
> 
> -- 
> 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
> [email protected] 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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to