mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
fix for custom associations in bake 1.2
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3680 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7554887b1e
commit
efa9eaba4d
1 changed files with 7 additions and 8 deletions
|
@ -483,9 +483,9 @@ class Bake {
|
||||||
//Look for belongsTo
|
//Look for belongsTo
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($modelFields as $field) {
|
foreach($modelFields as $field) {
|
||||||
if($field['type'] == 'integer'){
|
$tm = $this->__modelName($otherTable);
|
||||||
$possibleKeys[] = $field['name'];
|
$possibleKeys[$tm][] = $field['name'];
|
||||||
}
|
|
||||||
$offset = strpos($field['name'], '_id');
|
$offset = strpos($field['name'], '_id');
|
||||||
if($offset !== false) {
|
if($offset !== false) {
|
||||||
$tmpModelName = $this->__modelNameFromKey($field['name']);
|
$tmpModelName = $this->__modelNameFromKey($field['name']);
|
||||||
|
@ -502,9 +502,8 @@ class Bake {
|
||||||
$modelFieldsTemp = $db->describe($tempOtherModel);
|
$modelFieldsTemp = $db->describe($tempOtherModel);
|
||||||
$j = 0;
|
$j = 0;
|
||||||
foreach($modelFieldsTemp as $field) {
|
foreach($modelFieldsTemp as $field) {
|
||||||
if($field['type'] == 'integer'){
|
$tm = $this->__modelName($otherTable);
|
||||||
$possibleKeys[] = $field['name'];
|
$possibleKeys[$tm][] = $field['name'];
|
||||||
}
|
|
||||||
if($field['name'] == $this->__modelKey($currentModelName)) {
|
if($field['name'] == $this->__modelKey($currentModelName)) {
|
||||||
$tmpModelName = $this->__modelName($otherTable);
|
$tmpModelName = $this->__modelName($otherTable);
|
||||||
$hasOne[$j]['alias'] = $tmpModelName;
|
$hasOne[$j]['alias'] = $tmpModelName;
|
||||||
|
@ -666,8 +665,8 @@ class Bake {
|
||||||
$associationName = $this->getInput('What is the name of this association?');
|
$associationName = $this->getInput('What is the name of this association?');
|
||||||
$className = $this->getInput('What className will '.$associationName.' use?');
|
$className = $this->getInput('What className will '.$associationName.' use?');
|
||||||
$this->stdout('A helpful List of possible keys');
|
$this->stdout('A helpful List of possible keys');
|
||||||
for ($i = 0; $i < count($possibleKeys); $i++) {
|
for ($i = 0; $i < count($possibleKeys[$className]); $i++) {
|
||||||
$this->stdout($i + 1 . ". " . $possibleKeys[$i]);
|
$this->stdout($i + 1 . ". " . $possibleKeys[$className][$i]);
|
||||||
}
|
}
|
||||||
$foreignKey = $this->getInput('What is the foreignKey? Choose a number or specify your own.', null, $this->__modelKey($associationName));
|
$foreignKey = $this->getInput('What is the foreignKey? Choose a number or specify your own.', null, $this->__modelKey($associationName));
|
||||||
if (intval($foreignKey) > 0 && intval($foreignKey) <= $i ) {
|
if (intval($foreignKey) > 0 && intval($foreignKey) <= $i ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue