Hi All I am adding functionallity to a search page on a cakephp 1.1 website written early 2008. I am trying to search across 4 tables. Sources, Information, CodesInformation and Codes
I used the very clear and straightforward examples offer here: http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ Sources hasMany Infomation Information HABTM Codes. I have tried to force a join with the following bind logic: $this->Source->unbindModel(array('hasMany'=>array('Information'))); $this->Source->bindModel( array('hasOne' => array( 'Information'=>array(), 'CodesInformation' => array( 'foreignKey'=>false, 'conditions'=>array('CodesInformation.information_id = Searchtest.id')), 'Code'=>array( 'foreignKey'=>false, 'conditions'=>array('CodesInformation.code_id = Code.id')) ))); The resulting SQL statement is as follows: SELECT `Source`.`id`, `Source`.`type`, `Source`.`name`, `Source`.`rname`, `Source`.`memo`, `Source`.`created`, `Source`.`modified`, `Information`.`id`, `Information`.`source_id`, `Information`.`user_id`, `Information`.`source_description`, `Information`.`type`, `Information`.`title`, `Information`.`summary`, `Information`.`keyword`, `Information`.`comment`, `Information`.`shutsu_day`, `Information`.`kou_day`, `Information`.`hidden_flag`, `Information`.`edit_flag`, `Information`.`sendmail_flag`, `Information`.`sendmail_job_flag`, `Information`.`sendmail_time`, `Information`.`access_all`, `Information`.`news`, `Information`.`allcode`, `Information`.`created`, `Information`.`modified`, `CodesInformation`.`id`, `CodesInformation`.`information_id`, `CodesInformation`.`code_id`, `Code`.`id`, `Code`.`pid`, `Code`.`sequence`, `Code`.`level`, `Code`.`leaf`, `Code`.`code_name`, `Code`.`description`, `Code`.`rdescription`, `Code`.`sdescription`, `Code`.`alias`, `Code`.`created`, `Code`.`modified` FROM `sources` AS `Source` LEFT JOIN `information` AS `Information` ON (`Information`.`source_id` = `Source`.`id`) LEFT JOIN `codes_informations` AS `CodesInformation` ON (`CodesInformation`.`source_id` = `Source`.`id` AND `CodesInformation`.`information_id` = `Searchtest`.`id`) LEFT JOIN `codes` AS `Code` ON (`Code`.`source_id` = `Source`.`id` AND `CodesInformation`.`code_id` = `Code`.`id`) WHERE 1 = 1 LIMIT 10 <Error:> The error on the joins: `CodesInformation`.`source_id` = `Source`.`id` `Code`.`source_id` = `Source`.`id` How can I prevent the SQL statement adding these conditions to the ON? I just want the joins specified as I outlined in the conditions field when binding the model. Any help is greatly appreciated Thankyou Mich --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
