Fixes #3147, Bake not detecting all associations

Fixed typo in DboSource::name()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5622 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-09-10 11:18:52 +00:00
parent ed6b0d7649
commit a41b962ae5
2 changed files with 11 additions and 7 deletions

View file

@ -43,14 +43,14 @@ class ModelTask extends Shell {
if (empty($this->args)) {
$this->__interactive();
}
if (!empty($this->args[0])) {
$model = $this->args[0];
if ($this->__bake($model)) {
if ($this->_checkUnitTest()) {
$this->__bakeTest($model);
}
}
}
}
}
/**
@ -105,8 +105,12 @@ class ModelTask extends Shell {
loadModel();
$tempModel = new Model(false, $useTable);
$modelFields = $db->describe($tempModel);
if (isset($modelFields[0]['name']) && $modelFields[0]['name'] != 'id') {
$primaryKey = $this->in('What is the primaryKey?', null, $modelFields[0]['name']);
if (!array_key_exists('id', $modelFields)) {
foreach ($modelFields as $name => $field) {
break;
}
$primaryKey = $this->in('What is the primaryKey?', null, $name);
}
}
$validate = array();
@ -177,7 +181,7 @@ class ModelTask extends Shell {
foreach ($this->__tables as $otherTable) {
$tempOtherModel = & new Model(false, $otherTable);
$modelFieldsTemp = $db->describe($tempOtherModel);
foreach ($modelFieldsTemp as $field) {
foreach ($modelFieldsTemp as $fieldName => $field) {
if ($field['type'] == 'integer' || $field['type'] == 'string') {
$possibleKeys[$otherTable][] = $fieldName;
}

View file

@ -351,8 +351,8 @@ class DboSource extends DataSource {
}
$data = $this->startQuote . str_replace('.', $this->endQuote . '.' . $this->startQuote, $data) . $this->endQuote;
$data = str_replace($this->startQuote . $this->startQuote, $this->startQuote, $data);
$oddMatces = substr_count($data, $this->endQuote);
if ($oddMatces % 2 == 1) {
$oddMatches = substr_count($data, $this->endQuote);
if ($oddMatches % 2 == 1) {
$data = trim($data, $this->endQuote);
}
return str_replace($this->endQuote . $this->endQuote, $this->endQuote, $data);