Hi i have an error in the cake produced SQL when defining belongsTo association with conditions. Here the technical details: I have a table "Comments"
CREATE TABLE `comments` ( `id` int(64) NOT NULL auto_increment, `parentobject_id` int(64) NOT NULL default '0', `parentobject_lookup` varchar(255) NOT NULL default '', `user_id` int(32) NOT NULL default '0', `title` varchar(255) default NULL, `body` mediumtext, PRIMARY KEY (`id`) ) TYPE=MyISAM; I have the following association in the Comment model class var $belongsTo = array( 'Task' => array('className' => 'Task', 'foreignKey' => 'parentobject_id', 'conditions' => 'Comment.parentobject_lookup = \'Tasks\'', 'fields' => '', 'order' => '', 'counterCache' => '' ), 'Project' => array('className' => 'Project', 'foreignKey' => 'parentobject_id', 'conditions' => 'Comment.parentobject_lookup = \'Projects\'', 'fields' => '', 'order' => '', 'counterCache' => '' ), ); I am trying to bind comment to different parents by using parentobject_id => the id of the parent and parentobject_lookup=> the table that the id belongs to when i call findAll(); in the controller i always get an empty array. i traced the SQL produced by cake and found that it was: SELECT `Comment`.`id` * * * FROM `comments` AS `Comment` LEFT JOIN `tasks` AS `Task` ON `Comment`.`parentobject_id` = `Task`.`id` LEFT JOIN `projects` AS `Project` ON `Comment`.`parentobject_id` = `Project`.`id` WHERE ( Comment.parentobject_lookup = 'Projects') AND ( Comment.parentobject_lookup = 'Tasks') instead i think it should be SELECT `Comment`.`id` * * * FROM `comments` AS `Comment` LEFT JOIN `tasks` AS `Task` ON `Comment`.`parentobject_id` = `Task`.`id` AND Comment.parentobject_lookup = 'Tasks' LEFT JOIN `projects` AS `Project` ON `Comment`.`parentobject_id` = `Project`.`id` AND Comment.parentobject_lookup = 'Projects' I am not sure whether this is a bug or its my "twisted implementation" of the conditions in the cake associations. Any good ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---