mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #2457 from bar/2.5-getconstraint
Make getConstraint() a tiny bit more readable.
This commit is contained in:
commit
cf3cf551a6
1 changed files with 26 additions and 11 deletions
|
@ -1729,22 +1729,37 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
switch (true) {
|
||||
case ($assoc['external'] && $type === 'hasOne'):
|
||||
return array("{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}');
|
||||
case ($assoc['external'] && $type === 'belongsTo'):
|
||||
return array("{$alias}.{$linkModel->primaryKey}" => '{$__cakeForeignKey__$}');
|
||||
case (!$assoc['external'] && $type === 'hasOne'):
|
||||
return array("{$alias}.{$assoc['foreignKey']}" => $this->identifier("{$model->alias}.{$model->primaryKey}"));
|
||||
case (!$assoc['external'] && $type === 'belongsTo'):
|
||||
return array("{$model->alias}.{$assoc['foreignKey']}" => $this->identifier("{$alias}.{$linkModel->primaryKey}"));
|
||||
case ($type === 'hasOne' && $assoc['external']):
|
||||
return array(
|
||||
"{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}'
|
||||
);
|
||||
case ($type === 'hasOne' && !$assoc['external']):
|
||||
return array(
|
||||
"{$alias}.{$assoc['foreignKey']}" => $this->identifier("{$model->alias}.{$model->primaryKey}")
|
||||
);
|
||||
case ($type === 'belongsTo' && $assoc['external']):
|
||||
return array(
|
||||
"{$alias}.{$linkModel->primaryKey}" => '{$__cakeForeignKey__$}'
|
||||
);
|
||||
case ($type === 'belongsTo' && !$assoc['external']):
|
||||
return array(
|
||||
"{$model->alias}.{$assoc['foreignKey']}" => $this->identifier("{$alias}.{$linkModel->primaryKey}")
|
||||
);
|
||||
case ($type === 'hasMany'):
|
||||
return array("{$alias}.{$assoc['foreignKey']}" => array('{$__cakeID__$}'));
|
||||
return array(
|
||||
"{$alias}.{$assoc['foreignKey']}" => array('{$__cakeID__$}')
|
||||
);
|
||||
case ($type === 'hasAndBelongsToMany'):
|
||||
return array(
|
||||
array("{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}'),
|
||||
array("{$alias}.{$assoc['associationForeignKey']}" => $this->identifier("{$alias2}.{$linkModel->primaryKey}"))
|
||||
array(
|
||||
"{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}'
|
||||
),
|
||||
array(
|
||||
"{$alias}.{$assoc['associationForeignKey']}" => $this->identifier("{$alias2}.{$linkModel->primaryKey}")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue