Re: problem with HABTM find
I have the same problem too.. Then how to use this in pagination? Okto.Silaban.Net On Tue, Sep 9, 2008 at 6:48 PM, rob30 <[EMAIL PROTECTED]> wrote: > > $this->Conference->bindModel(array( >'hasOne' => array( > 'ConferencesSphere', > 'FilterSphere' => array( >'className' => 'Sphere', >'foreignKey' => false, >'conditions' => array('FilterSphere.id = > ConferencesSphere.sphere_id') > ; > $this->Conference->bindModel(array( >'hasOne' => array( > 'ConferencesInstitution', > 'FilterInstitution' => array( >'className' => 'Institution', >'foreignKey' => false, >'conditions' => array('FilterInstitution.id = > ConferencesInstitution.institution_id') > ; > > after such temp bind we can find conferences filtered by value of > spheres and institutions fields eg > $this->Conference->find('all', array('conditions' => > array('FilterSphere.name' => 'AJAX', 'FilterInstitution.name' => > 'something'), 'recursive' => 0, 'fields' => array('DISTINCT > Conference.id', 'Conference.*', 'FilterSphere.name'))); > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~--~~~~--~~--~--~---
Re: problem with HABTM find
$this->Conference->bindModel(array( 'hasOne' => array( 'ConferencesSphere', 'FilterSphere' => array( 'className' => 'Sphere', 'foreignKey' => false, 'conditions' => array('FilterSphere.id = ConferencesSphere.sphere_id') ; $this->Conference->bindModel(array( 'hasOne' => array( 'ConferencesInstitution', 'FilterInstitution' => array( 'className' => 'Institution', 'foreignKey' => false, 'conditions' => array('FilterInstitution.id = ConferencesInstitution.institution_id') ; after such temp bind we can find conferences filtered by value of spheres and institutions fields eg $this->Conference->find('all', array('conditions' => array('FilterSphere.name' => 'AJAX', 'FilterInstitution.name' => 'something'), 'recursive' => 0, 'fields' => array('DISTINCT Conference.id', 'Conference.*', 'FilterSphere.name'))); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~--~~~~--~~--~--~---
problem with HABTM find
Hi, Conference model: var $hasAndBelongsToMany = array('Sphere' => array('className'=> 'Sphere', 'joinTable'=> 'conferences_spheres', 'foreignKey' => 'conference_id', 'associationForeignKey'=> 'sphere_id', ), 'Institution'=> array('className'=> 'Institution', 'joinTable'=> 'conferences_institutions', 'foreignKey' => 'conference_id', 'associationForeignKey'=> 'institution_id', ) ); $this->Conference->find('all', array( 'recursive' => 1)); will create 3 sqls: SELECT ... FROM `conferences` AS `Conference` WHERE 1 = 1 SELECT ... FROM `spheres` AS `Sphere` JOIN `conferences_spheres` AS `ConferencesSphere` ON (`ConferencesSphere`.`conference_id` IN (1, 2, 3, 4, 7, 9, 10) AND `ConferencesSphere`.`sphere_id` = `Sphere`.`id`) WHERE 1 = 1 SELECT ... FROM `institutions` AS `Institution` JOIN `conferences_institutions` AS `ConferencesInstitution` ON (`ConferencesInstitution`.`conference_id` IN (1, 2, 3, 4, 7, 9, 10) AND `ConferencesInstitution`.`institution_id` = `Institution`.`id`) WHERE 1 = 1 how to find Conference where Sphere.name="something" and Institution.name="something" ?? such find: $this->Conference->find('all', array('conditions' => array('Sphere.name' => 'AJAX'), 'recursive' => 1)); generates bad sql: SELECT ... FROM `conferences` AS `Conference` WHERE `Sphere`.`name` = 'AJAX' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~--~~~~--~~--~--~---