mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fix for #1165.
Changing Model::__constructLinkedModel() to use the association name for the instance of an associated model. Changed DboSource::read() to use the association name. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3484 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
4f110a0ef9
commit
fc54b0f31a
3 changed files with 20 additions and 16 deletions
|
@ -630,7 +630,7 @@ class Controller extends Object {
|
|||
$model = $this->modelClass;
|
||||
$modelKey = $this->modelKey;
|
||||
$table = $this->{$model}->table;
|
||||
$association = array_search($table, $this->{$model}->alias);
|
||||
//$association = array_search($table, $this->{$model}->alias);
|
||||
$objRegistryModel =& ClassRegistry::getObject($modelKey);
|
||||
|
||||
foreach($objRegistryModel->_tableInfo as $tables) {
|
||||
|
@ -644,7 +644,7 @@ class Controller extends Object {
|
|||
}
|
||||
$fkNames = $this->{$model}->keyToTable[$tabl['name']];
|
||||
$fieldNames[$tabl['name']]['table'] = $fkNames[0];
|
||||
$association = array_search($fieldNames[$tabl['name']]['table'], $this->{$model}->alias);
|
||||
//$association = array_search($fieldNames[$tabl['name']]['table'], $this->{$model}->alias);
|
||||
$fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($niceName);
|
||||
$fieldNames[$tabl['name']]['model'] = $fkNames[1];
|
||||
$fieldNames[$tabl['name']]['modelKey'] = $this->{$model}->tableToModel[$fieldNames[$tabl['name']]['table']];
|
||||
|
@ -702,7 +702,7 @@ class Controller extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
$fieldNames[$tabl['name']]['selected'] = $data[$association][$tabl['name']];
|
||||
$fieldNames[$tabl['name']]['selected'] = $data[$model][$tabl['name']];
|
||||
}
|
||||
} else {
|
||||
$fieldNames[$tabl['name']]['type'] = 'input';
|
||||
|
|
|
@ -526,7 +526,7 @@ class DboSource extends DataSource {
|
|||
foreach($model->__associations as $type) {
|
||||
foreach($model->{$type} as $assoc => $assocData) {
|
||||
if ($model->recursive > -1) {
|
||||
$linkModel =& $model->{$assocData['className']};
|
||||
$linkModel =& $model->{$assoc};
|
||||
|
||||
if ($model->name == $linkModel->name && $type != 'hasAndBelongsToMany' && $type != 'hasMany') {
|
||||
if (true === $this->generateSelfAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, false, $null)) {
|
||||
|
@ -557,7 +557,7 @@ class DboSource extends DataSource {
|
|||
foreach($model->__associations as $type) {
|
||||
foreach($model->{$type} as $assoc => $assocData) {
|
||||
$db = null;
|
||||
$linkModel =& $model->{$assocData['className']};
|
||||
$linkModel =& $model->{$assoc};
|
||||
|
||||
if (!in_array($type . '/' . $assoc, $linkedModels)) {
|
||||
if ($model->useDbConfig == $linkModel->useDbConfig) {
|
||||
|
|
|
@ -554,21 +554,25 @@ class Model extends Overloadable {
|
|||
|
||||
if (ClassRegistry::isKeySet($colKey)) {
|
||||
if (!PHP5) {
|
||||
$this->{$className} =& ClassRegistry::getObject($colKey);
|
||||
$this->{$assoc} =& ClassRegistry::getObject($colKey);
|
||||
$this->{$className} =& $this->{$assoc};
|
||||
} else {
|
||||
$this->{$className} = ClassRegistry::getObject($colKey);
|
||||
$this->{$assoc} = ClassRegistry::getObject($colKey);
|
||||
$this->{$className} = $this->{$assoc};
|
||||
}
|
||||
} else {
|
||||
if (!PHP5) {
|
||||
$this->{$className} =& new $className($id, $table, $ds);
|
||||
$this->{$assoc} =& new $className($id, $table, $ds);
|
||||
$this->{$className} =& $this->{$assoc};
|
||||
} else {
|
||||
$this->{$className} = new $className($id, $table, $ds);
|
||||
$this->{$assoc} = new $className($id, $table, $ds);
|
||||
$this->{$className} = $this->{$assoc};
|
||||
}
|
||||
}
|
||||
|
||||
$this->alias[$assoc] = $this->{$className}->table;
|
||||
$this->tableToModel[$this->{$className}->table] = $className;
|
||||
$this->modelToTable[$className] = $this->{$className}->table;
|
||||
$this->alias[$assoc] = $this->{$assoc}->table;
|
||||
$this->tableToModel[$this->{$assoc}->table] = $assoc;
|
||||
$this->modelToTable[$assoc] = $this->{$assoc}->table;
|
||||
}
|
||||
/**
|
||||
* Build array-based association from string.
|
||||
|
@ -580,9 +584,9 @@ class Model extends Overloadable {
|
|||
foreach($this->{$type} as $assocKey => $assocData) {
|
||||
$class = $assocKey;
|
||||
|
||||
if (isset($this->{$type}[$assocKey]['className']) && $this->{$type}[$assocKey]['className'] !== null) {
|
||||
$class = $this->{$type}[$assocKey]['className'];
|
||||
}
|
||||
//if (isset($this->{$type}[$assocKey]['className']) && $this->{$type}[$assocKey]['className'] !== null) {
|
||||
// $class = $this->{$type}[$assocKey]['className'];
|
||||
//}
|
||||
|
||||
foreach($this->__associationKeys[$type] as $key) {
|
||||
if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] == null) {
|
||||
|
|
Loading…
Reference in a new issue