[请教] gii => Model Generator => Table 'break.account' does not exist.

数据库 帐号访问没有问题,只有使用 root 帐号才不会报错!为什么?请问怎么解决 Table ‘break.account’ does not exist?

Model Generator

This generator generates a model class for the specified database table.

Fields with * are required. Click on the highlighted fields to edit them.

Table Prefix

[empty]

This refers to the prefix name that is shared by all database tables. Setting this property mainly affects how model classes are named based on the table names. For example, a table prefix tbl_ with a table name tbl_post will generate a model class named Post.

Leave this field empty if your database tables do not use common prefix.

Table Name *

This refers to the table name that a new model class should be generated for (e.g. tbl_user). It can contain schema name, if needed (e.g. public.tbl_post). You may also enter * (or schemaName.* for a particular DB schema) to generate a model class for EVERY table.

[color="#FF0000"]Table ‘break.account’ does not exist.[/color]

Model Class *

This is the name of the model class to be generated (e.g. Post, Comment). It is case-sensitive.

Base Class *

CActiveRecord

This is the class that the new model class will extend from. Please make sure the class exists and can be autoloaded.

Model Path *

application.models

This refers to the directory that the new model class file should be generated under. It should be specified in the form of a path alias, for example, application.models.

Code Template *

default (D:\yii\framework\gii\generators\model\templates\default)

因为刚接触 Yii, 可不可以通过 config 来解决?

目前解决,采用变通方法:设定需要生成 model 的 DB 名字为 db, 通过 gii 生成完后, 修改 model 的默认 CDbConnection

class Account extends CActiveRecord

{

/**


 * Returns the static model of the specified AR class.


 * @return Account the static model class


 */


public static function model($className=__CLASS__)


{


	return parent::model($className);


}

[color="#FF0000"] public function getDbConnection()

{


     return Yii::app()->db2;


}[/color]

看看这个:

http://www.yiiframework.com/forum/index.php?/topic/5974-db-masterslave-issue/page__view__findpost__p__30669

3q!

:slight_smile: