I'm getting an annoying error:  Unknown column 'xxxxxx' in 'where
clause'

The error is correct based on the SQL that cake is generating.  But I
don't think cake should be generating the SQL it is.

When accessed via the AclAro model (below) it produces the desired
results - I get data from either the Group or User Model based on the
text content of AclAro.model - the SQL generated contains a seperate
LEFT JOIN for each condition.

class AclAro extends AppModel {
        var $name ='AclAro';
        var $useTable = 'aros';
        var $actsAs = array('Tree');

        var $belongsTo = array(
                        'Group' => array(
                                'className' => 'Group',
                                'foreignKey' => 'foreign_key',
                                'conditions' => array('AclAro.model' => 
'Group'),
                                'dependent' => false
                        ),
                        'User' => array(
                                'className' => 'Acl.AclUser',
                                'foreignKey' => 'foreign_key',
                                'conditions' => array('AclAro.model' => 'User'),
                                'dependent' => false
                        )
        );

}


However, I want to retrieve the User/Group data from another model
Permission that is associated with AclAro (below).  When I try to get
the desired data using 'recursive' => 2 it produces the error.  Cake
reworks the SQL, and attempts to make 1 SQL query for each each Group/
User and tries to apply the condition set in AclAro to the Group/User
table (the condition is a field in AclAro so doesn't exist in the
Group/User table hence the error when the SQL is run) i.e. it ignores
the AclAro condition on AclAro and tries to apply it to the wrong
table (by attempting to make 1 SQL query for each group/user the LEFT
JOIN's are removed).

class Permission extends AppModel {
        var $useTable = 'aros_acos';

        public $belongsTo = array(
                'AclAro' => array(
                        'className' => 'AclAro',
                        'foreignKey' => 'aro_id',
                ),
        );
}


In my method in the Permissions controller I'm using:

                $params = array('conditions' => array('aco_id' => 103), 
'recursive'
=> 2);  // hardcoded the 103 for testing
                $permissions = $this->AclPermission->find('all',$params);



Now I'm not sure if I'm doing something wrong or if its cake just
stuffing something up.  But I know I'm not getting the result I want.

Please help....................
--~--~---------~--~----~------------~-------~--~----~
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