I noticed there wasn't the ability to limit the fields in a hasMany,
hasOne, or belongsTo association in  LdapSource so I added one.  Below
is the code to replace generateAssociationQuery().  Make sure your
foreign key is within your limited fields if used.

function generateAssociationQuery(& $model, & $linkModel, $type,
$association = null, $assocData = array (), & $queryData, $external =
false, & $resultSet) {
                $this->__scrubQueryData($queryData);

                switch ($type) {
                        case 'hasOne' :
                                $id = 
$resultSet[$model->name][$model->primaryKey];
                                $queryData['conditions'] = 
trim($assocData['foreignKey']) . '=' .
trim($id);
                                $queryData['targetDn'] = $linkModel->useTable;
                                $queryData['type'] = 'search';
                                if 
(!empty($linkModel->hasOne[$model->name]['fields'])) {
                                        $queryData['fields'] = 
$linkModel->hasOne[$model->name]
['fields'];
                                }
                                $queryData['limit'] = 1;

                                return $queryData;

                        case 'belongsTo' :
                                $id = 
$resultSet[$model->name][$assocData['foreignKey']];
                                $queryData['conditions'] = trim($linkModel-
>primaryKey).'='.trim($id);
                                $queryData['targetDn'] = $linkModel->useTable;
                                $queryData['type'] = 'search';
                                $queryData['limit'] = 1;
                                if 
(!empty($linkModel->hasMany[$model->name]['fields'])) {
                                        $queryData['fields'] = 
$linkModel->hasMany[$model->name]
['fields'];
                                }
                                return $queryData;

                        case 'hasMany' :
                                $id = 
$resultSet[$model->name][strtolower($model->primaryKey)];
                                $queryData['conditions'] = 
trim($assocData['foreignKey']) . '=' .
trim($id);
                                $queryData['targetDn'] = $linkModel->useTable;
                                $queryData['type'] = 'search';
                                $queryData['limit'] = $assocData['limit'];
                                if 
(!empty($linkModel->belongsTo[$model->name]['fields'])) {
                                        $queryData['fields'] = 
$linkModel->belongsTo[$model->name]
['fields'];
                                }
                                return $queryData;

                        case 'hasAndBelongsToMany' :
                                return null;
                }
                return null;
        }

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

Reply via email to