本文整理汇总了PHP中OA_DB类的典型用法代码示例。如果您正苦于以下问题:PHP OA_DB类的具体用法?PHP OA_DB怎么用?PHP OA_DB使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OA_DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: alterDatabaseActionTable
function alterDatabaseActionTable()
{
$this->oSchema = MDB2_Schema::factory(OA_DB::singleton(OA_DB::getDsn()));
$prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
OA_DB::setCaseSensitive();
$aPrev = $this->oSchema->getDefinitionFromDatabase(array($prefix . 'database_action'));
OA_DB::disableCaseSensitive();
$aCurr = $this->_getLatestDatabaseActionSchema($prefix);
$aChanges = $this->oSchema->compareDefinitions($aCurr, $aPrev);
if (is_array($aChanges) && count($aChanges) > 0) {
if (isset($aChanges['tables']['change'][$prefix . 'database_action'])) {
if (isset($aChanges['tables']['change'][$prefix . 'database_action']['indexes']['add']['database_action_pkey'])) {
unset($aChanges['tables']['change'][$prefix . 'database_action']['indexes']['add']['database_action_pkey']);
unset($aChanges['tables']['change'][$prefix . 'database_action']['indexes']['change']);
}
if (isset($aChanges['tables']['change'][$prefix . 'database_action']['add']['database_action_id'])) {
$result = $this->oSchema->alterDatabase($aCurr, $aPrev, $aChanges);
if (PEAR::isError($result)) {
$this->oUpgrade->oLogger->logError($result->getUserInfo());
return false;
}
$this->oUpgrade->oLogger->log('database_action table schema successfully upgraded');
return true;
}
}
}
$this->oUpgrade->oLogger->log('database_action table schema upgrade unnecessary');
return true;
}
示例2: testSaveAllocatedImpressions
/**
* A method to test the saveAllocatedImpressions method.
*/
function testSaveAllocatedImpressions()
{
$oDbh =& OA_DB::singleton();
$oDal = new OA_Dal_Maintenance_Priority();
// Create the required temporary table for the tests
$oTable =& OA_DB_Table_Priority::singleton();
$oTable->createTable('tmp_ad_zone_impression');
// Prepare the test data
$aData = array(array('ad_id' => 56, 'zone_id' => 11, 'required_impressions' => 9997, 'requested_impressions' => 9000), array('ad_id' => 56, 'zone_id' => 12, 'required_impressions' => 24, 'requested_impressions' => 24));
$result = $oDal->saveAllocatedImpressions($aData);
$query = "SELECT * FROM " . $oDbh->quoteIdentifier('tmp_ad_zone_impression', true) . " ORDER BY ad_id, zone_id";
$rc = $oDbh->query($query);
$result = $rc->fetchAll();
$this->assertTrue(is_array($result));
$this->assertTrue(count($result) == 2);
$tmp = $result[0];
$this->assertTrue(array_key_exists('ad_id', $tmp));
$this->assertEqual($tmp['ad_id'], 56);
$this->assertTrue(array_key_exists('zone_id', $tmp));
$this->assertEqual($tmp['zone_id'], 11);
$this->assertTrue(array_key_exists('required_impressions', $tmp));
$this->assertEqual($tmp['required_impressions'], 9997);
$this->assertTrue(array_key_exists('requested_impressions', $tmp));
$this->assertEqual($tmp['requested_impressions'], 9000);
$tmp = $result[1];
$this->assertTrue(array_key_exists('ad_id', $tmp));
$this->assertEqual($tmp['ad_id'], 56);
$this->assertTrue(array_key_exists('zone_id', $tmp));
$this->assertEqual($tmp['zone_id'], 12);
$this->assertTrue(array_key_exists('required_impressions', $tmp));
$this->assertEqual($tmp['required_impressions'], 24);
$this->assertTrue(array_key_exists('requested_impressions', $tmp));
$this->assertEqual($tmp['requested_impressions'], 24);
TestEnv::dropTempTables();
}
示例3: 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
示例4: testAllMaintenanceStatisticsTables
/**
* Tests creating/dropping all of the MPE temporary tables.
*
* Requirements:
* Test 1: Test that all MPE temporary tables can be created and dropped.
*/
function testAllMaintenanceStatisticsTables()
{
$tmpTables = array('tmp_ad_impression', 'tmp_ad_click', 'tmp_tracker_impression_ad_impression_connection', 'tmp_tracker_impression_ad_click_connection', 'tmp_ad_connection');
// Test 1
$conf =& $GLOBALS['_MAX']['CONF'];
$conf['table']['prefix'] = '';
$oDbh =& OA_DB::singleton();
foreach ($tmpTables as $tableName) {
$query = "SELECT * FROM {$tableName}";
OA::disableErrorHandling();
$result = $oDbh->query($query);
OA::enableErrorHandling();
$this->assertEqual(strtolower(get_class($result)), 'mdb2_error');
}
$oTable =& OA_DB_Table_Statistics::singleton();
foreach ($tmpTables as $tableName) {
$oTable->createTable($tableName);
}
$aExistingTables = OA_DB_Table::listOATablesCaseSensitive();
foreach ($tmpTables as $tableName) {
// Test that the table has been created
$query = "SELECT * FROM {$tableName}";
$result = $oDbh->query($query);
$this->assertTrue($result);
// Test that the table can be dropped
// Use a different query to overcome MDB2 query buffering
$query = "SELECT foo FROM {$tableName}";
OA::disableErrorHandling();
$result = $oDbh->query($query);
OA::enableErrorHandling();
$this->assertEqual(strtolower(get_class($result)), 'mdb2_error');
}
// Restore the testing environment
TestEnv::restoreEnv();
}
示例5: setUp
function setUp()
{
$this->oDbh = OA_DB::singleton(OA_DB::getDsn());
$this->oTable = new OA_DB_Table();
$this->oTable->init(MAX_PATH . '/lib/OA/Upgrade/tests/data/migration_test_1.xml');
$this->aDefinition = $this->oTable->aDefinition;
}
示例6: Test_OA_DB_XmlCache
/**
* The constructor method.
*/
function Test_OA_DB_XmlCache()
{
$this->UnitTestCase();
$this->oDbh = OA_DB::singleton();
$this->oCache = new OA_DB_XmlCache();
$this->oSchema =& MDB2_Schema::factory($this->oDbh, array('force_defaults' => false));
}
示例7: __construct
/**
* Constructor
*
* @param array $conf array, if null reads the global variable
* @param array $pref array, if null reads the global variable
*/
function __construct($conf = null, $pref = null)
{
$this->aConf = is_null($conf) ? $GLOBALS['_MAX']['CONF'] : $conf;
$this->aPref = is_null($pref) ? $GLOBALS['_MAX']['PREF'] : $pref;
$this->_conf = $this->aConf['oacSync'];
$this->oDbh =& OA_DB::singleton();
}
示例8: __construct
/**
* The constructor method.
*/
function __construct()
{
parent::__construct();
$this->oDbh = OA_DB::singleton();
$this->oCache = new OA_DB_XmlCache();
$this->oSchema =& MDB2_Schema::factory($this->oDbh, array('force_defaults' => false));
}
示例9: removeDashboardColumns
function removeDashboardColumns()
{
$this->oSchema = MDB2_Schema::factory(OA_DB::singleton(OA_DB::getDsn()));
$prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
$table = 'preference';
$aColumns = array('ad_clicks_sum', 'ad_views_sum', 'ad_clicks_per_second', 'ad_views_per_second', 'ad_cs_data_last_sent', 'ad_cs_data_last_sent', 'ad_cs_data_last_received');
OA_DB::setCaseSensitive();
$aDef = $this->oSchema->getDefinitionFromDatabase(array($prefix . $table));
OA_DB::disableCaseSensitive();
if (is_array($aDef) && count($aDef) > 0) {
$aTask['remove'] = array();
if (isset($aDef['tables'][$prefix . $table])) {
foreach ($aColumns as $column) {
if (isset($aDef['tables'][$prefix . $table]['fields'][$column])) {
$aTask['remove'][$column] = array();
$this->oUpgrade->oLogger->logOnly("preference.{$column} found");
}
}
}
if (count($aTask['remove'] > 0)) {
$result = $this->oSchema->db->manager->alterTable($prefix . $table, $aTask, false);
}
}
$this->oUpgrade->oLogger->logOnly('preference table schema upgrade for dashboard unnecessary');
return true;
}
示例10: testSqlForInsert
function testSqlForInsert()
{
$sql = OA_DB_Sql::sqlForInsert('zones', array('zonetype' => 1, 'name' => "120x72"));
$oDbh = OA_DB::singleton();
$table = $oDbh->quoteIdentifier($this->getPrefix() . 'zones', true);
$this->assertEqual("INSERT INTO {$table} (zonetype,name) VALUES (1,'120x72')", $sql);
}
示例11: UserMigration
function UserMigration()
{
// We will need the admin and per-agency languages to assign the correct "Default" languages to advertiser and websites
if (!$this->init(OA_DB::singleton())) {
$this->_logError('Failed to initialise UserMigration class');
return false;
}
$this->_log('Initialised UserMigration class, construction begun');
$table = $this->_getQuotedTableName('preference');
// Get admin language
$query = "\n SELECT\n agencyid AS id,\n language AS language\n FROM\n {$table}\n WHERE\n agencyid = 0\n ";
$adminLang = $this->oDBH->getAssoc($query);
if (PEAR::isError($adminLang)) {
$this->_logError("Error while retrieving admin language: " . $adminLang->getUserInfo());
return false;
}
// Get agency languages
$table = $this->_getQuotedTableName('agency');
$query = "\n SELECT\n agencyid AS id,\n language AS language\n FROM\n {$table}";
$agencyLang = $this->oDBH->getAssoc($query);
if (PEAR::isError($agencyLang)) {
$this->_logError("Error while retrieving agency languages: " . $agencyLang->getUserInfo());
return false;
}
// Set the admin's language for id 0, then set each agencies language as specified, using admins if unset
$this->aLanguageByAgency[0] = !empty($adminLang[0]) ? $adminLang[0] : 'english';
foreach ($agencyLang as $id => $language) {
if (!empty($language)) {
$this->aLanguageByAgency[$id] = $language;
} else {
$this->aLanguageByAgency[$id] = $this->aLanguageByAgency[0];
}
}
$this->_log('UserMigration class, construction complete');
}
示例12: _getValidCampaigns
/**
* A method that uses the getAllCampaigns() method to obtain all campaigns
* that meet the requirements of this class. That is:
*
* - The campaign is active, and has a priority of at least 1; and
* - The campaign has daily inventory requirements.
*
* @access private
* @return array An array of {@link OX_Maintenance_Priority_Campaign} objects.
*/
function _getValidCampaigns()
{
$conf = $GLOBALS['_MAX']['CONF'];
$oDbh = OA_DB::singleton();
$table = $oDbh->quoteIdentifier($conf['table']['prefix'] . $conf['table']['campaigns'], true);
$aWheres = array(array("{$table}.priority >= 1", 'AND'), array("{$table}.status = " . OA_ENTITY_STATUS_RUNNING, 'AND'), array("({$table}.target_impression > 0 OR {$table}.target_click > 0 OR {$table}.target_conversion > 0)", 'AND'), array("({$table}.expire_time IS NULL OR ({$table}.views = -1 AND {$table}.clicks = -1 AND {$table}.conversions = -1))", 'AND'));
return $this->_getAllCampaigns($aWheres);
}
示例13: init
function init($aParams)
{
$this->className = get_class($this);
$this->oDBUpgrade = $aParams[0];
$this->_log('****************************************');
$this->oDbh = OA_DB::singleton(OA_DB::getDsn());
return true;
}
示例14: _getAuditObject
function _getAuditObject($classToTest)
{
$oAuditor = new $classToTest();
$oDbh = OA_DB::singleton(OA_DB::getDsn());
$oAuditor->prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
$oAuditor->oDbh = $oDbh;
return $oAuditor;
}
示例15: __construct
function __construct()
{
// Get a connection to the datbase
$this->oDbh =& OA_DB::singleton();
// Locate all plugins (packages) that have been installed
$oPluginManager = new OX_PluginManager();
$this->aPackages = $oPluginManager->getPackagesList();
}