本文整理汇总了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.");
}