mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-02 07:39:45 +00:00
Model objects should be in CamelCase.
This commit is contained in:
parent
014d2dd2d9
commit
c1f3d9c274
1 changed files with 15 additions and 15 deletions
|
@ -1580,7 +1580,7 @@ class DboSource extends DataSource {
|
||||||
* Generates an array representing a query or part of a query from a single model or two associated models.
|
* Generates an array representing a query or part of a query from a single model or two associated models.
|
||||||
*
|
*
|
||||||
* @param Model $Model
|
* @param Model $Model
|
||||||
* @param Model $linkModel If null
|
* @param Model $LinkModel
|
||||||
* @param string $type Association type, one of the model association types ie. hasMany
|
* @param string $type Association type, one of the model association types ie. hasMany
|
||||||
* @param string $association
|
* @param string $association
|
||||||
* @param array $assocData
|
* @param array $assocData
|
||||||
|
@ -1589,7 +1589,7 @@ class DboSource extends DataSource {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* True. when $external is false and association $type is 'hasOne' or 'belongsTo'.
|
* True. when $external is false and association $type is 'hasOne' or 'belongsTo'.
|
||||||
*/
|
*/
|
||||||
public function generateAssociationQuery(Model $Model, $linkModel, $type, $association, $assocData, &$queryData, $external) {
|
public function generateAssociationQuery(Model $Model, $LinkModel, $type, $association, $assocData, &$queryData, $external) {
|
||||||
$assocData = $this->_scrubQueryData($assocData);
|
$assocData = $this->_scrubQueryData($assocData);
|
||||||
|
|
||||||
if ($external && !empty($assocData['finderQuery'])) {
|
if ($external && !empty($assocData['finderQuery'])) {
|
||||||
|
@ -1607,10 +1607,10 @@ class DboSource extends DataSource {
|
||||||
case 'belongsTo':
|
case 'belongsTo':
|
||||||
$conditions = $this->_mergeConditions(
|
$conditions = $this->_mergeConditions(
|
||||||
$assocData['conditions'],
|
$assocData['conditions'],
|
||||||
$this->getConstraint($type, $Model, $linkModel, $association, array_merge($assocData, compact('external')))
|
$this->getConstraint($type, $Model, $LinkModel, $association, array_merge($assocData, compact('external')))
|
||||||
);
|
);
|
||||||
|
|
||||||
$selfJoin = ($Model->name === $linkModel->name);
|
$selfJoin = ($Model->name === $LinkModel->name);
|
||||||
|
|
||||||
if ($external && !$selfJoin) {
|
if ($external && !$selfJoin) {
|
||||||
$modelAlias = $Model->alias;
|
$modelAlias = $Model->alias;
|
||||||
|
@ -1624,14 +1624,14 @@ class DboSource extends DataSource {
|
||||||
if ($external) {
|
if ($external) {
|
||||||
$query = array_merge($assocData, array(
|
$query = array_merge($assocData, array(
|
||||||
'conditions' => $conditions,
|
'conditions' => $conditions,
|
||||||
'table' => $this->fullTableName($linkModel),
|
'table' => $this->fullTableName($LinkModel),
|
||||||
'fields' => $this->fields($linkModel, $association, $assocData['fields']),
|
'fields' => $this->fields($LinkModel, $association, $assocData['fields']),
|
||||||
'alias' => $association,
|
'alias' => $association,
|
||||||
'group' => null
|
'group' => null
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$join = array(
|
$join = array(
|
||||||
'table' => $linkModel,
|
'table' => $LinkModel,
|
||||||
'alias' => $association,
|
'alias' => $association,
|
||||||
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
||||||
'conditions' => trim($this->conditions($conditions, true, false, $Model))
|
'conditions' => trim($this->conditions($conditions, true, false, $Model))
|
||||||
|
@ -1641,7 +1641,7 @@ class DboSource extends DataSource {
|
||||||
|
|
||||||
$fields = array();
|
$fields = array();
|
||||||
if ($assocData['fields'] !== false) {
|
if ($assocData['fields'] !== false) {
|
||||||
$fields = $this->fields($linkModel, $association, $assocData['fields']);
|
$fields = $this->fields($LinkModel, $association, $assocData['fields']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$queryData['fields'] = array_merge($this->prepareFields($Model, $queryData), $fields);
|
$queryData['fields'] = array_merge($this->prepareFields($Model, $queryData), $fields);
|
||||||
|
@ -1658,15 +1658,15 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'hasMany':
|
case 'hasMany':
|
||||||
$assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']);
|
$assocData['fields'] = $this->fields($LinkModel, $association, $assocData['fields']);
|
||||||
if (!empty($assocData['foreignKey'])) {
|
if (!empty($assocData['foreignKey'])) {
|
||||||
$assocData['fields'] = array_merge($assocData['fields'], $this->fields($linkModel, $association, array("{$association}.{$assocData['foreignKey']}")));
|
$assocData['fields'] = array_merge($assocData['fields'], $this->fields($LinkModel, $association, array("{$association}.{$assocData['foreignKey']}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = array(
|
$query = array(
|
||||||
'conditions' => $this->_mergeConditions($this->getConstraint('hasMany', $Model, $linkModel, $association, $assocData), $assocData['conditions']),
|
'conditions' => $this->_mergeConditions($this->getConstraint('hasMany', $Model, $LinkModel, $association, $assocData), $assocData['conditions']),
|
||||||
'fields' => array_unique($assocData['fields']),
|
'fields' => array_unique($assocData['fields']),
|
||||||
'table' => $this->fullTableName($linkModel),
|
'table' => $this->fullTableName($LinkModel),
|
||||||
'alias' => $association,
|
'alias' => $association,
|
||||||
'order' => $assocData['order'],
|
'order' => $assocData['order'],
|
||||||
'limit' => $assocData['limit'],
|
'limit' => $assocData['limit'],
|
||||||
|
@ -1700,15 +1700,15 @@ class DboSource extends DataSource {
|
||||||
'conditions' => $assocData['conditions'],
|
'conditions' => $assocData['conditions'],
|
||||||
'limit' => $assocData['limit'],
|
'limit' => $assocData['limit'],
|
||||||
'offset' => $assocData['offset'],
|
'offset' => $assocData['offset'],
|
||||||
'table' => $this->fullTableName($linkModel),
|
'table' => $this->fullTableName($LinkModel),
|
||||||
'alias' => $association,
|
'alias' => $association,
|
||||||
'fields' => array_merge($this->fields($linkModel, $association, $assocData['fields']), $joinFields),
|
'fields' => array_merge($this->fields($LinkModel, $association, $assocData['fields']), $joinFields),
|
||||||
'order' => $assocData['order'],
|
'order' => $assocData['order'],
|
||||||
'group' => null,
|
'group' => null,
|
||||||
'joins' => array(array(
|
'joins' => array(array(
|
||||||
'table' => $joinTbl,
|
'table' => $joinTbl,
|
||||||
'alias' => $joinAssoc,
|
'alias' => $joinAssoc,
|
||||||
'conditions' => $this->getConstraint('hasAndBelongsToMany', $Model, $linkModel, $joinAlias, $assocData, $association)
|
'conditions' => $this->getConstraint('hasAndBelongsToMany', $Model, $LinkModel, $joinAlias, $assocData, $association)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue