本文整理汇总了PHP中OA_DB::createFunctions方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_DB::createFunctions方法的具体用法?PHP OA_DB::createFunctions怎么用?PHP OA_DB::createFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_DB
的用法示例。
在下文中一共展示了OA_DB::createFunctions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($aParams)
{
$this->oUpgrade = $aParams[0];
if ($this->oUpgrade->oDbh->dbsyntax == 'pgsql') {
$prefix = $this->oUpgrade->oDBUpgrader->prefix;
$result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$prefix}zones ALTER zonename TYPE varchar(245)");
// This ALTER TABLE needs to run in UTC because it stores a UTC timestamp
$result = $this->oUpgrade->oDbh->exec("SET timezone = 'UTC'");
$result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$prefix}session ALTER lastused TYPE timestamp");
$result = $this->oUpgrade->oDbh->exec("SET timezone = DEFAULT");
$result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$prefix}images ALTER t_stamp TYPE timestamp");
$result = $this->oUpgrade->oDbh->exec("DROP INDEX " . OA_phpAdsNew::phpPgAdsPrefixedIndex('banners_clientid_idx', $prefix));
$result = $this->oUpgrade->oDbh->exec("DROP INDEX " . OA_phpAdsNew::phpPgAdsPrefixedIndex('clients_parent_idx', $prefix));
$result = $this->oUpgrade->oDbh->exec("DROP INDEX " . OA_phpAdsNew::phpPgAdsPrefixedIndex('zones_affiliateid_idx', $prefix));
$aForeignKeys = $this->oUpgrade->oDbh->getAssoc("\n SELECT\n r.conname AS fk,\n c.relname AS table\n FROM\n pg_catalog.pg_class c JOIN\n pg_catalog.pg_constraint r ON (r.conrelid = c.oid)\n WHERE\n c.relname IN ('{$prefix}acls', '{$prefix}banners', '{$prefix}clients', '{$prefix}zones') AND\n pg_catalog.pg_table_is_visible(c.oid) AND\n r.contype = 'f'\n ORDER BY\n 1,2\n ");
foreach ($aForeignKeys as $fkey => $table) {
$result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$table} DROP CONSTRAINT {$fkey}");
}
$aIndexes = array(OA_phpAdsNew::phpPgAdsPrefixedIndex('acls_bannerid_idx', $prefix) => 'acls_bannerid', OA_phpAdsNew::phpPgAdsPrefixedIndex('acls_bannerid_executionorder_udx', $prefix) => 'acls_bannerid_executionorder', OA_phpAdsNew::phpPgAdsPrefixedIndex('acls_bannerid_idx', $prefix) => 'acls_bannerid', OA_phpAdsNew::phpPgAdsPrefixedIndex('adclicks_bid_date_idx', $prefix) => 'adclicks_bannerid_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adclicks_date_idx', $prefix) => 'adclicks_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adclicks_zoneid_idx', $prefix) => 'adclicks_zoneid', OA_phpAdsNew::phpPgAdsPrefixedIndex('adstats_bid_day_idx', $prefix) => 'adstats_bannerid_day', OA_phpAdsNew::phpPgAdsPrefixedIndex('adstats_zoneid_idx', $prefix) => 'adstats_zoneid', OA_phpAdsNew::phpPgAdsPrefixedIndex('adviews_bid_date_idx', $prefix) => 'adviews_bannerid_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adviews_date_idx', $prefix) => 'adviews_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adviews_zoneid_idx', $prefix) => 'adviews_zoneid', OA_phpAdsNew::phpPgAdsPrefixedIndex('zones_zonename_zoneid_idx', $prefix) => 'zones_zonenameid');
foreach ($aIndexes as $oldIndex => $newIndex) {
$result = $this->oUpgrade->oDbh->exec("ALTER INDEX {$oldIndex} RENAME TO {$prefix}{$newIndex}");
}
$aFunctions = array('unix_timestamp(timestamptz)', 'from_unixtime(int4)', 'to_days(timestamptz)', 'dayofmonth(timestamptz)', 'month(timestamptz)', 'year(timestamptz)', 'week(timestamptz)', 'hour(timestamptz)', 'date_format(timestamptz, text)', 'if(bool, varchar, varchar)');
foreach ($aFunctions as $function) {
$result = $this->oUpgrade->oDbh->exec("DROP FUNCTION {$function}");
}
OA_DB::createFunctions();
}
return true;
}
开发者ID:hostinger,项目名称:revive-adserver,代码行数:30,代码来源:prescript_openads_upgrade_2.0.11_to_2.3.32_beta.php
示例2: setupDB
/**
* A method for setting up a test database.
*
* @param bool $ignore_errors True if setup errors should be ignored.
*/
static function setupDB($ignore_errors = false)
{
$oDbh =& OA_DB::singleton();
if (PEAR::isError($oDbh)) {
$aConf = $GLOBALS['_MAX']['CONF'];
$result = OA_DB::createDatabase($aConf['database']['name']);
if (PEAR::isError($result) && !$ignore_errors) {
PEAR::raiseError("TestEnv unable to create the {$aConf['database']['name']} test database." . $result->getUserInfo(), PEAR_LOG_ERR);
die(1);
}
$result = OA_DB::createFunctions();
if (PEAR::isError($result) && !$ignore_errors) {
PEAR::raiseError("TestEnv unable to create the required functions." . $result->getUserInfo(), PEAR_LOG_ERR);
die(1);
}
}
}
示例3: setSchema
/**
* A method to set the default schema. The schema will be created if missing.
*
* @param MDB2_Driver_common $oDbh
* @return mixed True on succes, PEAR_Error otherwise
*/
static function setSchema($oDbh)
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Connect to PgSQL schema if needed
if ($oDbh->dbsyntax == 'pgsql' && !empty($oDbh->connected_database_name)) {
if (empty($aConf['databasePgsql']['schema'])) {
// No need to deal with schemas
return true;
}
OA::disableErrorHandling();
$result = $oDbh->exec("SET search_path = '{$aConf['databasePgsql']['schema']}'");
OA::enableErrorHandling();
if (PEAR::isError($result)) {
// Schema not found, try to create it
OA::disableErrorHandling();
$schema = $oDbh->quoteIdentifier($aConf['databasePgsql']['schema'], true);
$result = $oDbh->exec("CREATE SCHEMA {$schema}");
OA::enableErrorHandling();
if (PEAR::isError($result)) {
// Schema was not created, return error
return $result;
}
OA::disableErrorHandling();
$result = $oDbh->exec("SET search_path = '{$aConf['databasePgsql']['schema']}'");
OA::enableErrorHandling();
if (PEAR::isError($result)) {
// Schema was created, but SET search_path failed...
return $result;
}
OA::disableErrorHandling();
$result = OA_DB::createFunctions();
OA::enableErrorHandling();
if (PEAR::isError($result)) {
// Could not create functions
return $result;
}
}
}
return true;
}
示例4: upgrade
/**
* prepare to execute the upgrade steps
* assumes that you have run canUpgrade first (to detect install and determine versionInitialApplication)
* execute milestones followed by incremental packages
* this method is called recursively for incremental packages
* audit each package execution
*
*
* @return boolean
*/
function upgrade($input_file = '', $timing = 'constructive')
{
// only need to disable plugins once
static $plugins_disabled;
if (!$plugins_disabled) {
$this->disableAllPlugins();
$plugins_disabled = true;
}
// initialise database connection if necessary
if (is_null($this->oDbh)) {
$this->initDatabaseConnection();
}
if (!$this->checkPermissionToCreateTable()) {
$this->oLogger->logError('Insufficient database permissions or incorrect database settings');
return false;
}
// first deal with each of the packages in the list
// that was compiled during detection
if (count($this->aPackageList) > 0) {
foreach ($this->aPackageList as $k => $this->package_file) {
if (!$this->upgradeExecute($this->package_file)) {
$halt = true;
break;
}
}
}
if ($halt) {
return false;
}
// when upgrading from a milestone version such as pan or max
// run through this upgrade again
// else finish by doing a *version stamp* upgrade
if ($this->upgrading_from_milestone_version) {
// if openads installed was not on
// set installed on so openads can be detected
$GLOBALS['_MAX']['CONF']['openads']['installed'] = 1;
if ($this->detectOpenads()) {
if (!$this->upgrade()) {
$GLOBALS['_MAX']['CONF']['openads']['installed'] = 0;
$this->_removeInstalledFlagFile();
return false;
}
}
} else {
$version = OA_VERSION;
if ($this->seekFantasyUpgradeFile()) {
$version = '999.999.999';
$this->createFantasyRecoveryFile();
}
$this->package_file = 'openads_version_stamp_' . $version;
$this->oLogger->setLogFile($this->_getUpgradeLogFileName($timing));
$this->oDBUpgrader->logFile = $this->oLogger->logFile;
$this->oAuditor->setUpgradeActionId();
$this->oAuditor->setKeyParams(array('upgrade_name' => $this->package_file, 'version_to' => $version, 'version_from' => $this->getProductApplicationVersion(true), 'logfile' => basename($this->oLogger->logFile)));
$this->oAuditor->logAuditAction(array('description' => 'FAILED', 'action' => UPGRADE_ACTION_UPGRADE_FAILED));
// Update SQL functions to the latest version
if (PEAR::isError(OA_DB::createFunctions())) {
$this->oLogger->logError('Failed to update SQL functions');
$this->message = 'Failed to update SQL functions';
return false;
}
// Reparse the config file to ensure that new items are loaded
$this->oConfiguration->aConfig = $GLOBALS['_MAX']['CONF'];
if (!$this->_upgradeConfig()) {
$this->oLogger->logError('Failed to upgrade configuration file');
return false;
}
if ($this->versionInitialApplication != $version) {
if (!$this->oVersioner->putApplicationVersion($version)) {
$this->oLogger->logError('Failed to update application version to ' . $version);
$this->message = 'Failed to update application version to ' . $version;
return false;
}
$this->versionInitialApplication = $this->oVersioner->getApplicationVersion();
$this->oLogger->log('Application version updated to ' . $version);
}
$this->oAuditor->updateAuditAction(array('description' => 'UPGRADE_COMPLETE', 'action' => UPGRADE_ACTION_UPGRADE_SUCCEEDED, 'confbackup' => $this->oConfiguration->getConfigBackupName()));
$this->_writeRecoveryFile();
$this->_pickupNoBackupsFile();
}
$this->_writePostUpgradeTasksFile();
$this->_pickupRecoveryFile();
return true;
}
示例5: __construct
function __construct()
{
parent::__construct();
OA_DB::createFunctions();
}
示例6: _backup
/**
* create uniquely named copies of affected tables
* audit each backup
*
* @return boolean
*/
function _backup()
{
if ($this->doBackups) {
$aTables = $this->aChanges['affected_tables'][$this->timingStr];
$this->aDBTables = $this->_listTables();
if (!empty($aTables)) {
$this->oAuditor->logAuditAction(array('info1' => 'BACKUP STARTED', 'action' => DB_UPGRADE_ACTION_BACKUP_STARTED));
// Create backup SQL functions if needed
$result = OA_DB::createFunctions(true);
if ($this->_isPearError($result, 'error creating backup SQL functions')) {
$this->_halt();
$this->oAuditor->logAuditAction(array('info1' => 'BACKUP FAILED', 'info2' => 'creating backup SQL functions', 'action' => DB_UPGRADE_ACTION_BACKUP_FAILED));
return false;
}
// Backup tables
foreach ($aTables as $k => &$table) {
if (in_array($this->prefix . $table, $this->aDBTables)) {
$string = $this->versionTo . $this->timingStr . $this->database . $this->prefix . $table . OA::getNow();
// Create the table name using a 64bit hex string (16 char)
// Uniqueness is guaranteed using a second crc32 call with a
// slightly modified string
$table_bak = sprintf('z_%08x%08x', crc32($string), crc32("@" . $string));
$this->aMessages[] = "backing up table {$this->prefix}{$table} to table {$this->prefix}{$table_bak} ";
$statement = $this->aSQLStatements['table_copy'];
$query = sprintf($statement, $this->prefix . $table_bak, $this->prefix . $table);
$result = $this->oSchema->db->exec($query);
if ($this->_isPearError($result, 'error creating backup')) {
$this->_halt();
$this->oAuditor->logAuditAction(array('info1' => 'BACKUP FAILED', 'info2' => 'creating backup table' . $table_bak, 'action' => DB_UPGRADE_ACTION_BACKUP_FAILED));
return false;
}
$aDef = $this->_getDefinitionFromDatabase($table);
$aBakDef = $aDef['tables'][$table];
// keeping the restore array alive is no longer necessary after refactored recovery
// $this->aRestoreTables[$table] = array(
// 'bak'=>$table_bak,
// 'def'=>$aBakDef
// );
$this->oAuditor->logAuditAction(array('info1' => 'copied table', 'tablename' => $table, 'tablename_backup' => $table_bak, 'table_backup_schema' => serialize($aBakDef), 'action' => DB_UPGRADE_ACTION_BACKUP_TABLE_COPIED));
} else {
$this->aAddedTables[$table] = true;
}
}
$this->oAuditor->logAuditAction(array('info1' => 'BACKUP COMPLETE', 'action' => DB_UPGRADE_ACTION_BACKUP_SUCCEEDED));
} else {
$this->oAuditor->logAuditAction(array('info1' => 'BACKUP UNNECESSARY', 'action' => DB_UPGRADE_ACTION_BACKUP_SUCCEEDED));
}
} else {
$this->oAuditor->logAuditAction(array('info1' => 'BACKUP IGNORED', 'action' => DB_UPGRADE_ACTION_BACKUP_IGNORED));
}
return true;
}
示例7: LibAclTest
function LibAclTest()
{
$this->UnitTestCase();
OA_DB::createFunctions();
}