Wednesday, March 2, 2011

HABTM... again

Hello!
I'm trying to get some data using habtm.
here is the code:

$this->Article->bindModel(array('hasOne'=>array('ArticlesTag')));
$tags = $this->Article->Tag-
>find('list',array('conditions'=>array('ArticlesTag.article_id'=>
$id)));

The source is from the manual.
Now the error:

Warning (512): SQL Error: 1054: Unknown column
'ArticlesTag.article_id' in 'where clause' [APP\cake\libs\model
\datasources\dbo_source.php, line 681]
Query: SELECT `Tag`.`id`, `Tag`.`name` FROM `tags` AS `Tag` WHERE
`ArticlesTag`.`article_id` = 36

I just can't figure out what's wrong. What am i missing? i read the
manual + some blog entries about habtm but i don't feel like i'm
closer to the goal.

Another thing: When one record from "articles" table is deleted
(trough cake), all of the joins are deleted too. Help me!

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