model and db_config task fixes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5760 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-10-15 07:48:19 +00:00
parent 9c7f0755a5
commit 68c63b67f3
2 changed files with 21 additions and 16 deletions

View file

@ -37,6 +37,11 @@ if (!class_exists('File')) {
*/
class DbConfigTask extends Shell {
var $__defaultConfig = array('name' => 'default', 'driver'=> 'mysql', 'persistent'=> 'false', 'host'=> 'localhost',
'login'=> 'root', 'password'=> 'password', 'database'=> 'project_name',
'schema'=> null, 'prefix'=> null);
/**
* Execution method always used for tasks
*
@ -143,10 +148,7 @@ class DbConfigTask extends Shell {
* @return bool
*/
function __verify($config) {
$defaults = array('name' => 'default', 'driver'=> 'mysql', 'persistent'=> 'false', 'host'=> 'localhost',
'login'=> 'root', 'password'=> 'password', 'database'=> 'project_name',
'schema'=> null,'prefix'=> null);
$config = am($defaults, $config);
$config = am($this->__defaultConfig, $config);
extract($config);
$this->out('');
$this->hr();
@ -165,7 +167,7 @@ class DbConfigTask extends Shell {
$looksGood = $this->in('Look okay?', array('y', 'n'), 'y');
if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
return true;
return $config;
}
return false;
}
@ -184,6 +186,7 @@ class DbConfigTask extends Shell {
$out .= "class DATABASE_CONFIG {\n\n";
foreach ($configs as $config) {
$config = am($this->__defaultConfig, $config);
extract($config);
$out .= "\tvar \${$name} = array(\n";
$out .= "\t\t'driver' => '{$driver}',\n";

View file

@ -853,6 +853,7 @@ class Model extends Overloadable {
* @deprecated
*/
function loadInfo($clear = false) {
if (!is_object($this->_tableInfo) || $clear) {
$info = $this->schema($clear);
$fields = array();
foreach($info->value as $field => $value) {
@ -860,6 +861,7 @@ class Model extends Overloadable {
}
unset($info);
$this->_tableInfo = new Set($fields);
}
return $this->_tableInfo;
}
/**