samokspv/cakephp-db-configure
Composer 安装命令:
composer require samokspv/cakephp-db-configure
包简介
Use it if you want to save and read serialized data into DB.
README 文档
README
DBConfigure plugin for CakePHP 2.2+
Use it if you want to save and read serialized data into/from DB (DBConfigure::read = (Configure::write + DBConfigure::write)).
Installation
cd my_cake_app/app
git clone git://github.com/samokspv/cakephp-DBConfigure.git Plugin/DBConfigure
or if you use git add as submodule:
cd my_cake_app
git submodule add "git://github.com/samokspv/cakephp-DBConfigure.git" "app/Plugin/DBConfigure"
then add plugin loading in Config/bootstrap.php
CakePlugin::load('DBConfigure');
Usage
In any place of your code:
App::uses('DBConfigure', 'DBConfigure.Utility');
For example:
// save to DB
DBConfigure::write('TestSetting', array(
'key_1' => array(
'key_1_1' => 'value_1_1',
'key_1_2' => array(
'key_1_2_1' => 'value_1_2_1'
)
)
));
// read from DB
DBConfigure::read('TestSetting');
/*return: array(
'key_1' => array(
'key_1_1' => 'value_1_1',
'key_1_2' => array(
'key_1_2_1' => 'value_1_2_1'
)
)
)*/
DBConfigure::read('TestSetting.key_1');
/*return: array(
'key_1_1' => 'value_1_1',
'key_1_2' => array(
'key_1_2_1' => 'value_1_2_1'
)
)*/
DBConfigure::read('TestSetting.key_1.key_1_2');
/*return: array(
'key_1_2_1' => 'value_1_2_1'
)*/
DBConfigure::read('TestSetting.key_1_3', 'defaultValue_1_3');
/*return: defaultValue_1_3*/
// save to DB
DBConfigure::write('TestSetting.key_1.key_1_2', 'value_1_2_1_update');
// read from DB
DBConfigure::read('TestSetting.key_1.key_1_2');
/*return: array(
'key_1_2_1' => 'value_1_2_1_update'
)*/
// save to session
Configure::write('TestSetting.key_1', 'value_1');
Configure::write('TestSetting.key_2', 'value_2');
// save to DB
DBConfigure::write('TestSetting.key_2', 'value_2_update');
DBConfigure::write('TestSetting.key_3', 'value_3');
// read from DB
DBConfigure::read('TestSetting');
/*return: array(
'key_1' => 'value_1',
'key_2' => 'value_2_update',
'key_3' => 'value_3'
)*/
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-07