本文整理匯總了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());
}
}