当前位置: 首页>>代码示例>>PHP>>正文


PHP OA_DB::singleton方法代码示例

本文整理汇总了PHP中OA_DB::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_DB::singleton方法的具体用法?PHP OA_DB::singleton怎么用?PHP OA_DB::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OA_DB的用法示例。


在下文中一共展示了OA_DB::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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');
 }
开发者ID:villos,项目名称:tree_admin,代码行数:35,代码来源:UserMigration.php

示例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();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:38,代码来源:Priority_AdImpressions.dal.test.php

示例3: 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();
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:41,代码来源:Statistics.tbl.test.php

示例4: while

 /**
  * A factory method which returns the currently supported best advisory lock
  * instance.
  *
  * @return OA_DB_AdvisoryLock Reference to an OA_DB_AdvisoryLock object.
  */
 function &factory($sType = null)
 {
     if (is_null($sType)) {
         $oDbh =& OA_DB::singleton();
         if (PEAR::isError($oDbh)) {
             OA::debug('Error connecting to database to obtain locking object. Native error follows:', PEAR_LOG_ERR);
             OA::debug($oDbh, PEAR_LOG_ERR);
             OA::debug('Will re-try connection...', PEAR_LOG_ERR);
             $retryCount = 0;
             while (PEAR::isError($oDbh) && $retryCount < 6) {
                 $retryCount++;
                 sleep(10);
                 OA::debug('Re-try connection attempt #' . $retryCount, PEAR_LOG_ERR);
                 $oDbh =& OA_DB::singleton();
             }
             if (PEAR::isError($oDbh)) {
                 OA::debug('Failed in re-try attempts to connect to database. Aborting.', PEAR_LOG_CRIT);
                 exit;
             }
         }
         $aDsn = MDB2::parseDSN($oDbh->getDSN());
         $sType = $aDsn['phptype'];
     }
     include_once MAX_PATH . '/lib/OA/DB/AdvisoryLock/' . $sType . '.php';
     $sClass = "OA_DB_AdvisoryLock_" . $sType;
     $oLock = new $sClass();
     if (!$oLock->_isLockingSupported()) {
         // Fallback to file based locking if the current class won't work
         $oLock =& OA_DB_AdvisoryLock::factory('file');
     }
     return $oLock;
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:38,代码来源:AdvisoryLock.php

示例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;
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:7,代码来源:Migration.up.test.php

示例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));
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:10,代码来源:XmlCache.tbl.test.php

示例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();
 }
开发者ID:indyshao,项目名称:revive-adserver,代码行数:13,代码来源:Sync.php

示例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));
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:10,代码来源:XmlCache.tbl.test.php

示例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;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:26,代码来源:postscript_openads_upgrade_2.3.36-beta-rc1.php

示例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);
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:7,代码来源:Sql.tbl.test.php

示例11: 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;
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:29,代码来源:prescript_openads_upgrade_2.3.33-beta-rc4.php

示例12: __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();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:8,代码来源:MigrateBucketData.php

示例13: _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);
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:18,代码来源:GetRequiredAdImpressionsDaily.php

示例14: 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;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:8,代码来源:script_tables_core_parent.php

示例15: _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;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:8,代码来源:BaseUpgradeAuditor.up.test.php


注:本文中的OA_DB::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。