I am building a component with model access to query some additional
data (I know using a model in a component is not best practice, but I
need it here that way!). For that purpose I use
loadModel($attachedModel);
$this->{$attachedModel} = new $attachedModel;
It works fine as long I do not try to limit by HABTM data. Using
findall() without condition returns e.g.
Array
(
[0] => Array
(
[UrlattachedNote] => Array <-- $attachedModel
(
[id] => 1
....
[created] => 2008-04-18 16:41:27
)
[UrlattachedPath] => Array <--- HABTM data
(
[0] => Array
(
[id] => 1
[name] => test1
[controller] => pages
)
[1] => Array
(
...
)
)
)
whareas findall(array('UrlattachedPath.controller'=>'pages')) returns
an error
Query: SELECT `UrlattachedNote`.`id`, `UrlattachedNote`.`title`,
`UrlattachedNote`.`body`, `UrlattachedNote`.`is_admin`,
`UrlattachedNote`.`is_hidden`, `UrlattachedNote`.`is_preview`,
`UrlattachedNote`.`is_datelimited`,
`UrlattachedNote`.`limit_startdate`,
`UrlattachedNote`.`limit_enddate`,
`UrlattachedNote`.`preview_of_model`, `UrlattachedNote`.`modified`,
`UrlattachedNote`.`created` FROM `cake_urlattached_notes` AS
`UrlattachedNote` WHERE `UrlattachedPath`.`controller` = 'pages'
Warning (512): SQL Error: 1109: Unknown table 'UrlattachedPath' in
where clause [CORE/cake/libs/model/datasources/dbo_source.php, line
463]
The HABTM join is not present in the query. Why?
Christian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---