Hello Together,
I want to link two Models without using a Foreign Key, but using some
Conditions instead. Here is my example:

Model:
---------
class Category extends AppModel {
        var $name = "Category";
        var $actsAs = array("Containable");

        var $hasMany = array(
                "Zone" => array(
                        "foreignKey" => false,
                        "conditions" => array(
                                "AND" => array("Category.width = Zone.width", 
"Category.height =
Zone.height")
                        )
                )
        );
}

Controller:
--------------
$category = $this->Category->find("first", array(
        "conditions" => array("Category.id" => 1),
        "contain" => array(
                "Zone"
        )
));

Result:
----------
>>SQL Error: 1054: Unknown column 'Category.width' in 'where clause'<<

That seems clear if you make a look on the generated Query:
>>SELECT ... FROM 'zones' AS 'Zone' WHERE (('Category'.'width' = 
>>'Zone'.'width') AND ('Category'.'height' = 'Zone'.'height')) <<

No Join occurs - but why? Can anybody help me out?
I appreciate any help on this issue.

Regards.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to