slwalker / mysql_util
CakePHP MySQL Util 插件
1.0.0
2013-03-08 09:04 UTC
Requires
- php: >=5.3.0
- composer/installers: *
This package is not auto-updated.
Last update: 2024-09-14 14:17:58 UTC
README
使用复制
如果操作使用写入模型方法,使用主数据库。
在Innodb中使用UUID
CakePHP 忽略哑主键。使用哑主键提升MySQL写入性能
如何使用
database.php
<?php
class DATABASE_CONFIG {
/**
* Slave DB Config as defult
*
* driver => The name of a supported driver; valid options are as follows:
* MysqlUtil.Database/Innodb - MySQL Innodb,
*
* master =>
* the name that master's config
*
* dammy =>
* the dammy primary field name when it uses uuid primary in innodb
*
* @var array
*/
public $default = array(
'datasource' => 'MysqlUtil.Database/Innodb',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
'encoding' => 'utf8',
'master' => 'master',
'dammy' => 'added_id',
);
/**
* Master DB Config
*
* master =>
* the name that master's config
*
* @var array
*/
public $master = array(
'datasource' => 'MysqlUtil.Database/Innodb',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
'encoding' => 'utf8',
'dammy' => 'added_id',
);
}
AppModel.php
<?php
App::uses('ReplicationBaseModel', 'MysqlUtil.Model');
class AppModel extends ReplicationBaseModel {
}
在SomeModel中使用SQL_NO_CACHE
$this->getDataSource()->setNoCache(true);
回滚
$this->getDataSource()->setNoCache(false);