Tuesday, December 20, 2011

Re: HABTM example for CakeDC Search plugin

This is what I have currently:

var $filterArgs = array(
array('name' => 'filter', 'type' => 'query', 'method' =>
'orConditions'),
array('name' => 'filter', 'type' => 'subquery', 'method' =>
'findByTags', 'field' => 'NewsPost.id'),
);

public function findByTags($data = array()) {
$this->NewsPostsNewsTag->Behaviors->attach('Containable',
array('autoFields' => false));
$this->NewsPostsNewsTag->Behaviors->attach('Search.Searchable');
$query = $this->NewsPostsNewsTag->getQuery('all', array(
'conditions' => array('NewsTag.name' => $data['filter']),
'fields' => array('news_post_id'),
'contain' => array('NewsTag')
));
return $query;
}

But I'm now getting:

Warning (512): Model "NewsPostsNewsTag" is not associated with model
"NewsTag" [CORE\cake\libs\model\behaviors\containable.php, line 343]

Which is strange, as I wasn't getting that error before?

TIA,

d//t

On Dec 20, 3:13 pm, "designv...@gmail.com" <designv...@gmail.com>
wrote:
> Yep! Sure did!
>
> I was fairly sure I had followed everything correctly, but I kept
> getting "Operand should contain 1 column" error?
>
> I looked at debug and the 'tags' portion of the query was returning
> all the fields not just the id's?
>
> I think it's something to do with containable, but I couldn't figure
> it out at all!
>
> d//t
>
> On Dec 20, 2:50 pm, José Lorenzo <jose....@gmail.com> wrote:
>
>
>
>
>
>
>
> > Did you read this?
>
> >http://cakedc.com/downloads/view/cakephp_search_plugin

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