This commit is contained in:
qiang.xue
2010-04-05 02:43:41 +00:00
parent ff1acf3999
commit d7c1010e20
2 changed files with 26 additions and 16 deletions

View File

@@ -53,9 +53,18 @@ class ModelCode extends CCodeModel
$this->files=array();
$templatePath=$this->templatePath;
$params=array(
'tableName'=>$this->removePrefix($this->tableName),
'modelClass'=>$this->modelClass,
'columns'=>$this->getColumns(),
'labels'=>$this->getLabels(),
'rules'=>$this->getRules(),
'relations'=>$this->getRelations(),
);
$this->files[]=new CCodeFile(
Yii::getPathOfAlias($this->modelPath).'/'.$this->modelClass.'.php',
$this->render($templatePath.'/model.php')
$this->render($templatePath.'/model.php', $params)
);
}
@@ -161,11 +170,6 @@ class ModelCode extends CCodeModel
return isset($relations[$this->modelClass]) ? $relations[$this->modelClass] : array();
}
public function getTableNameWithoutPrefix()
{
return $this->removePrefix($this->tableName);
}
protected function removePrefix($tableName,$addBrackets=true)
{
$prefix=$this->tablePrefix!='' ? $this->tablePrefix : Yii::app()->db->tablePrefix;