本文整理匯總了PHP中owa_coreAPI::updateFactory方法的典型用法代碼示例。如果您正苦於以下問題:PHP owa_coreAPI::updateFactory方法的具體用法?PHP owa_coreAPI::updateFactory怎麽用?PHP owa_coreAPI::updateFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類owa_coreAPI
的用法示例。
在下文中一共展示了owa_coreAPI::updateFactory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Checks for and applies schema upgrades for the module
*
*/
function update()
{
// list files in a directory
$files = owa_lib::listDir(OWA_DIR . 'modules' . '/' . $this->name . '/' . 'updates', false);
//print_r($files);
$current_schema_version = $this->c->get($this->name, 'schema_version');
// extract sequence
foreach ($files as $k => $v) {
// the use of %d casts the sequence number as an int which is critical for maintaining the
// order of the keys in the array that we are going ot create that holds the update objs
//$n = sscanf($v['name'], '%d_%s', $seq, $classname);
$seq = substr($v['name'], 0, -4);
settype($seq, "integer");
if ($seq > $current_schema_version) {
if ($seq <= $this->required_schema_version) {
$this->updates[$seq] = owa_coreAPI::updateFactory($this->name, substr($v['name'], 0, -4));
// if the cli update mode is required and we are not running via cli then return an error.
owa_coreAPI::debug('cli update mode required: ' . $this->updates[$seq]->isCliModeRequired());
if ($this->updates[$seq]->isCliModeRequired() === true && !defined('OWA_CLI')) {
//set flag in module
$this->update_from_cli_required = true;
owa_coreAPI::notice("Aborting update {$seq}. This update must be applied using the command line interface.");
return false;
}
// set schema version from sequence number in file name. This ensures that only one update
// class can ever be in use for a particular schema version
$this->updates[$seq]->schema_version = $seq;
}
}
}
// sort the array
ksort($this->updates, SORT_NUMERIC);
//print_r(array_keys($this->updates));
foreach ($this->updates as $k => $obj) {
$this->e->notice(sprintf("Applying Update %d (%s)", $k, get_class($obj)));
$ret = $obj->apply();
if ($ret == true) {
$this->e->notice("Update Suceeded");
} else {
$this->e->notice("Update Failed");
return false;
}
}
return true;
}
示例2: rollback
function rollback($update)
{
list($module, $seq) = explode('.', $update);
$u = owa_coreAPI::updateFactory($module, $seq);
$u->rollback();
owa_coreAPI::notice("Rollback completed.");
}