本文整理匯總了PHP中base_kvstore::config_persistent方法的典型用法代碼示例。如果您正苦於以下問題:PHP base_kvstore::config_persistent方法的具體用法?PHP base_kvstore::config_persistent怎麽用?PHP base_kvstore::config_persistent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類base_kvstore
的用法示例。
在下文中一共展示了base_kvstore::config_persistent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: command_kvrecovery
function command_kvrecovery($instance = null)
{
if (!is_null($instance) && !defined('FORCE_KVSTORE_STORAGE')) {
$instance = trim($instance);
if (!(strpos($instance, '_') === 0)) {
$instance = 'base_kvstore_' . $instance;
}
define('FORCE_KVSTORE_STORAGE', $instance);
}
base_kvstore::config_persistent(false);
$testObj = base_kvstore::instance('test');
if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
kernel::log('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
exit;
}
kernel::log('KVstore Recovery...');
$db = kernel::database();
$count = $db->count('SELECT count(*) AS count FROM sdb_base_kvstore', true);
if (empty($count)) {
kernel::log('No data recovery');
exit;
}
$pagesize = 100;
$page = ceil($count / 100);
for ($i = 0; $i < $page; $i++) {
$rows = $db->selectlimit('SELECT * FROM sdb_base_kvstore', $pagesize, $i * $pagesize);
foreach ($rows as $row) {
//kernel::log($row['key']);continue;
$row['value'] = unserialize($row['value']);
//todo:合法數據
if (base_kvstore::instance($row['prefix'])->recovery($row)) {
kernel::log($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Success');
} else {
kernel::log($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Failure');
}
}
}
}
示例2: command_kvrecovery
public function command_kvrecovery($instance = null)
{
if (app::get('base')->status() == 'uninstalled') {
logger::info('係統未安裝!請先運行install');
return;
}
base_kvstore::config_persistent(false);
//臨時禁用KV持久化 TODO 比較危險
$testObj = base_kvstore::instance('test');
if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
logger::info('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
exit;
}
logger::info('KVrecovery BEGIN...');
$db = vmc::database();
$count = $db->count('SELECT count(*) AS count FROM vmc_base_kvstore', true);
if (empty($count)) {
logger::info('No data recovery');
exit;
}
$pagesize = 100;
$page = ceil($count / 100);
for ($i = 0; $i < $page; $i++) {
$rows = $db->selectlimit('SELECT * FROM vmc_base_kvstore', $pagesize, $i * $pagesize);
foreach ($rows as $row) {
$arr_value = unserialize($row['value']);
if (!$arr_value || !is_array($arr_value)) {
logger::error($row['prefix'] . '=>' . $row['key'] . ' ... KVrecovery ERROR');
}
$row['value'] = $arr_value;
if (base_kvstore::instance($row['prefix'])->recovery($row)) {
logger::info($row['prefix'] . '=>' . $row['key'] . ' ... KVrecovery Success');
} else {
logger::warning($row['prefix'] . '=>' . $row['key'] . ' ... KVrcovery Failure');
}
}
}
logger::info('KVrecovery END...');
}
示例3: command_kvrecovery
function command_kvrecovery($instance = null)
{
if (!is_null($instance)) {
$instance = trim($instance);
if (!(strpos($instance, '_') === 0)) {
$instance = 'base_kvstore_' . $instance;
}
config::set('kvstore.default', $instance);
}
base_kvstore::config_persistent(false);
$testObj = base_kvstore::instance('test');
if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
logger::info('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
exit;
}
logger::info('KVstore Recovery...');
$db = app::get('base')->database();
$count = $db->executeQuery('SELECT count(*) AS count FROM base_kvstore')->fetchColumn();
if (!$count) {
logger::info('No data recovery');
exit;
}
$pagesize = 100;
$page = ceil($count / 100);
for ($i = 0; $i < $page; $i++) {
$rows = $db->executeQuery('SELECT * FROM base_kvstore limit ? offset ?', [$pagesize, $pagesize * $i])->fetchAll();
foreach ($rows as $row) {
//logger::info($row['key']);continue;
$row['value'] = unserialize($row['value']);
//todo:合法數據
if (base_kvstore::instance($row['prefix'])->recovery($row)) {
logger::info($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Success');
} else {
logger::info($row['prefix'] . '=>' . $row['key'] . ' ... Recovery Failure');
}
}
}
}