In the 'Complex Find Conditions (using arrays)' section of the Models
chapter in the manual (http://manual.cakephp.org/chapter/models), it
is suggested that you can search multiple models using a conditions
array such as:

array
("Author.name" => "Bob", "or" => array
    (
        "Post.title" => "LIKE %magic%",
        "Post.created" => "> " . date('Y-m-d', strtotime("-2 weeks")
    )
)

which would find all the posts that contain a certain keyword or that
were created in the past two weeks, but were written by Bob.

I am trying to apply this example to two models that are associated by
a HABTM relationship (i.e. Post and Tag), so that I can search for
posts that were created after a certain date, that are also tagged
with some keyword.

i.e. my conditions array looks like:
array
(
    "Tag.name" = "LIKE %magic%",
    "Post.created" => "> " . date('Y-m-d', strtotime("-2 weeks")
)

However, when I execute $this->Post->findAll() using this conditions
array from my posts_controller, I receive an error saying 'SQL Error
in model Post: 1054: Unknown column 'Tag.name' in 'where clause'',
after examining the SQL that is generated by Cake it is clear that the
tags table isn't being referenced at all by the query.

Have I missed something here? Are these kinds of complex find
conditions expected to work for HABTM models?

Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to