关于Yii连接多个数据库

我的一个项目中,要连接多个数据库,想问一下数据库要如何配置?

如何用Model命令生成?

还有,如果说一张表表名是Tab_user,那Model文件生成的文件名会是什么样呢?

有没有Model命令的详解?

你可以类似'db'声明多个数据库连接,例如'db2', 'db3'。在程序里可以通过Yii::app()->db2来访问。

AR缺省是使用'db'连接的。下面这段话是guide里的:

If you want to use an application component other than db, or if you want to work with multiple databases using AR, you should override CActiveRecord::getDbConnection(). The CActiveRecord class is the base class for all AR classes.

    Tip: There are two ways to work with multiple databases in AR. If the schemas of the databases are different, you may create different base AR classes with different implementation of getDbConnection(). Otherwise, dynamically changing the static variable CActiveRecord::db is a better idea.

在使用model命令时,你可以通过help model命令查看具体帮助信息。

现在支持主从吗??

支持主从读写分离吗

Yii本身没有提供这个功能。Yii提供的就是多数据库连接。具体的主从读写分离支持,我们将在1.1考虑支持。

1.0分支会加入主从吗?

项目已经用了1.0的了。。

因为1.0比较稳定。。