Tuesday, August 25, 2015

Re: HABTM example for CakeDC Search plugin

Sorry for digging this up but as we all know history repeats itself ;-)

I have the same error that tells me that the latter model in a HABTM relation is not associated with the relation-table. I wonder if you could resolve this issue? 

Am Dienstag, 20. Dezember 2011 16:23:45 UTC+1 schrieb desig...@gmail.com:
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

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: