本文整理汇总了PHP中Updater::updateDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Updater::updateDatabase方法的具体用法?PHP Updater::updateDatabase怎么用?PHP Updater::updateDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Updater
的用法示例。
在下文中一共展示了Updater::updateDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateDatabase
/**
* @param $uid
* @param $handle
* @param bool $dbBackupPath
*
* @throws Exception
* @return array
*/
public function updateDatabase($uid, $handle, $dbBackupPath = false)
{
Craft::log('Starting to update the database.', LogLevel::Info, true);
try {
$updater = new Updater();
if ($handle == 'craft') {
Craft::log('Craft wants to update the database.', LogLevel::Info, true);
$updater->updateDatabase($uid, $dbBackupPath);
Craft::log('Craft is done updating the database.', LogLevel::Info, true);
} else {
$plugin = craft()->plugins->getPlugin($handle);
if ($plugin) {
Craft::log('The plugin, ' . $plugin->getName() . ' wants to update the database.', LogLevel::Info, true);
$updater->updateDatabase($uid, $dbBackupPath, $plugin);
Craft::log('The plugin, ' . $plugin->getName() . ' is done updating the database.', LogLevel::Info, true);
} else {
Craft::log('Cannot find a plugin with the handle ' . $handle . ' or it is not enabled, therefore it cannot update the database.', LogLevel::Error);
throw new Exception(Craft::t('Cannot find an enabled plugin with the handle {handle}.', array('handle' => $handle)));
}
}
return array('success' => true);
} catch (\Exception $e) {
return array('success' => false, 'message' => $e->getMessage());
}
}