V9数据模型功能,允许用户把不同的数据表,分离到不同的数据库服务器上。以实现负载的分离,更加的符合大访问网站的需求。
配置文件路径:caches\configs\database.php
return array ( 'default' => array ( 'hostname' => 'localhost', 'database' => 'phpcmsv9', 'username' => 'admin', 'password' => 'admin', 'tablepre' => 'v9_', 'charset' => 'gbk', 'type' => 'mysql', 'debug' => true, 'pconnect' => 0, 'autoconnect' => 0 ), /*可以根据自己需求设置多个数据库链接配置*/ 'link1' => array ( 'hostname' => 'localhost', 'database' => 'comment', 'username' => 'admin', 'password' => 'admin', 'tablepre' => 'v9_', 'charset' => 'gbk', 'type' => 'mysql', 'debug' => true, 'pconnect' => 0, 'autoconnect' => 0 ), 'link2' => array ( 'hostname' => 'localhost', 'database' => 'workflow', 'username' => 'admin', 'password' => 'admin', 'tablepre' => 'v9_', 'charset' => 'gbk', 'type' => 'mysql', 'debug' => true, 'pconnect' => 0, 'autoconnect' => 0 ), );
配置文件路径:phpcms\model中所有文件
该目录下所有*_model.class.php都是数据模型文件
例如:workflow_model.class.php
defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_sys_class('model', '', 0); class workflow_model extends model { public function __construct() { $this->db_config = pc_base::load_config('database'); $this->db_setting = 'link2'; //可以通过修改db_setting设置该数据表所链接的数据库服务器 $this->table_name = 'workflow'; parent::__construct(); } }