本文整理汇总了PHP中OA_Dal::factoryDO方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_Dal::factoryDO方法的具体用法?PHP OA_Dal::factoryDO怎么用?PHP OA_Dal::factoryDO使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_Dal
的用法示例。
在下文中一共展示了OA_Dal::factoryDO方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _iterateTableFields
/**
* This function iterates over the table fields, and either gathers data which would be changed, or changes the data
*
* @param array $aTableFields
* @return array
*/
function _iterateTableFields($aTableFields, $execute = false)
{
$aChanged = array();
$encTo = !empty($_POST['encTo']) ? $_POST['encTo'] : 'UTF-8';
$encFrom = !empty($_POST['encFrom']) ? $_POST['encFrom'] : 'UTF-8';
foreach ($aTableFields as $table => $tableData) {
$doTable = OA_Dal::factoryDO($table);
$doTable->find();
while ($doTable->fetch()) {
$changed = false;
foreach ($tableData['fields'] as $field) {
$converted = MAX_commonConvertEncoding($doTable->{$field}, $encTo, $encFrom);
if ($converted === $doTable->{$field}) {
continue;
}
$id = array();
foreach ($tableData['idfields'] as $idField) {
$id[$idField] = $doTable->{$idField};
}
if ($execute && !in_array(implode('.', $id), $_POST['aExecute'][$table][$field])) {
continue;
}
$aChanged[$table][$field][] = array('from' => $doTable->{$field}, 'to' => $converted, 'id' => $id);
$doTable->{$field} = $converted;
$changed = true;
}
if ($changed && $execute) {
$doTable->update();
}
}
}
return $aChanged;
}
示例2: testGetPublishersByTracker
function testGetPublishersByTracker()
{
$campaignId = 1;
// Add a couple of campaign_trackers
$doCampaignsTrackers = OA_Dal::factoryDO('campaigns_trackers');
$doCampaignsTrackers->campaignid = $campaignId;
$doCampaignsTrackers->trackerid = 1;
$aCampaignTrackerId = DataGenerator::generate($doCampaignsTrackers, 2);
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->campaignid = $campaignId;
$doBanners->acls_updated = '2007-04-03 18:39:45';
$bannerId = DataGenerator::generateOne($doBanners, true);
// Add a couple of affiliates
$aAffiliateId = DataGenerator::generate('affiliates', 2);
$doZones = OA_Dal::factoryDO('zones');
$doZones->affiliateid = $aAffiliateId[0];
$zoneId = DataGenerator::generateOne($doZones);
$doAddZoneAssoc = OA_Dal::factoryDO('ad_zone_assoc');
$doAddZoneAssoc->zone_id = $zoneId;
$doAddZoneAssoc->ad_id = $BannerId;
$adZoneAssocId = DataGenerator::generateOne($doAddZoneAssoc);
// Test the correct number of rows is returned.
$expectedRows = 1;
$rsAffiliates = $this->dalAffiliates->getPublishersByTracker($aCampaignTrackerId[0]);
$rsAffiliates->find();
$actualRows = $rsAffiliates->getRowCount();
$this->assertEqual($actualRows, $expectedRows);
}
示例3: md5
function &staticGetApi($createDefaultManager = true)
{
$oApi =& $GLOBALS['_STATIC']['staticGetApi'];
if (empty($oApi)) {
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_type = OA_ACCOUNT_ADMIN;
$adminAccountId = DataGenerator::generateOne($doAccounts);
if ($createDefaultManager) {
$doAgency = OA_Dal::factoryDO('agency');
$doAgency->name = 'Default Manager';
$agencyId = DataGenerator::generateOne($doAgency);
$doAgency = OA_Dal::staticGetDO('agency', $agencyId);
$managerAccountId = $doAgency->account_id;
}
$doUsers = OA_Dal::factoryDO('users');
$doUsers->username = 'admin_' . md5(uniqid('', true));
$doUsers->password = md5('secret');
$doUsers->default_account_id = $createDefaultManager ? $managerAccountId : $adminAccountId;
$userId = DataGenerator::generateOne($doUsers);
$doAUA = OA_Dal::factoryDO('account_user_assoc');
$doAUA->account_id = $adminAccountId;
$doAUA->user_id = $userId;
DataGenerator::generateOne($doAUA);
$oApi = new Mocked_OA_Api_Xmlrpc($doUsers->username, 'secret');
}
return $oApi;
}
示例4: OA_Central_M2M
/**
* Class constructor
*
* @param string $accountId If null, the current account ID is used
* @param string $accountType If null, the current account type is used
* @return OA_Central_M2M
*/
function OA_Central_M2M($accountId = null)
{
parent::OA_Central_Common();
$currentId = OA_Permission::getAccountId();
if (is_null($accountId)) {
$this->accountId = $currentId;
} else {
$this->accountId = $accountId;
}
if ($this->accountId == $currentId) {
$this->accountType = OA_Permission::getAccountType();
} else {
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->account_id = $this->accountId;
$doAccounts->find();
if ($doAccounts->fetch()) {
$this->accountType = $doAccounts->account_type;
} else {
Max::raiseError('Unexisting account ID', null, PEAR_ERROR_DIE);
}
}
if ($this->accountType == OA_ACCOUNT_ADMIN) {
$this->accountId = 0;
}
}
示例5: checkRangeData
/**
* A mathod to quickly check the data in the database for the date
* range given, to ensure that the range being tested & corrected
* seems reasonable.
*
* @param Date $oStartDate The start date/time of the range to test & correct.
* @param Date $oEndDate The end date/time of the range to test & correct.
* @return boolean True if the date range seems okay, false otherwise.
*/
function checkRangeData($oStartDate, $oEndDate)
{
// Test that there are no rows in the data_intermediate_ad table where the
// operation interval value does not match that in the configuration file
$doData_intermediate_ad = OA_Dal::factoryDO('data_intermediate_ad');
$doData_intermediate_ad->whereAdd('date_time >= ' . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
$doData_intermediate_ad->whereAdd('date_time <= ' . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
$doData_intermediate_ad->whereAdd('operation_interval != ' . $this->oDbh->quote(OX_OperationInterval::getOperationInterval(), 'integer'));
$doData_intermediate_ad->find();
$rows = $doData_intermediate_ad->getRowCount();
if ($rows > 0) {
$message = "\n Detected at least one row in the data_intermediate_ad table with operation interval != " . OX_OperationInterval::getOperationInterval() . ".\n";
echo $message;
return false;
}
// Test that all of the date/time values in the data_summary_ad_hourly
// table align with the start of operation intervals
$doData_summary_ad_hourly = OA_Dal::factoryDO('data_summary_ad_hourly');
$doData_summary_ad_hourly->selectAdd();
$doData_summary_ad_hourly->selectAdd('DISTINCT date_time');
$doData_summary_ad_hourly->whereAdd('date_time >= ' . $this->oDbh->quote($oStartDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
$doData_summary_ad_hourly->whereAdd('date_time <= ' . $this->oDbh->quote($oEndDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
$doData_summary_ad_hourly->find();
while ($doData_summary_ad_hourly->fetch()) {
$oDate = new Date($doData_summary_ad_hourly->date_time);
$result = OX_OperationInterval::checkDateIsStartDate($oDate);
if (!$result) {
$message = "\n Detected at least one row in the data_summary_ad_hourly table with date_time value not on the hour start interval.\n";
echo $message;
return false;
}
}
return true;
}
示例6: testUpdateWhereOne
function testUpdateWhereOne()
{
$this->initTables(array('campaigns', 'trackers'));
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'First';
$doCampaigns->views = 10;
$campaignId1 = DataGenerator::generateOne($doCampaigns);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Third';
$doCampaigns->views = 30;
$campaignId2 = DataGenerator::generateOne($doCampaigns);
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->campaignname = 'Fifth';
$doCampaigns->views = 50;
$campaignId3 = DataGenerator::generateOne($doCampaigns);
$cUpdated = OA_DB_Sql::updateWhereOne('campaigns', 'campaignid', $campaignId2, array('campaignname' => 'Second', 'views' => 20));
$this->assertEqual(1, $cUpdated);
$doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId2);
$this->assertEqual('Second', $doCampaigns->campaignname);
$this->assertEqual(20, $doCampaigns->views);
$doCampaigns = OA_Dal::staticGetDO('campaigns', $campaignId1);
$this->assertEqual('First', $doCampaigns->campaignname);
$this->assertEqual('10', $doCampaigns->views);
$aConf = $GLOBALS['_MAX']['CONF'];
$this->oaTable->dropTable($aConf['table']['prefix'] . 'campaigns');
$this->oaTable->dropTable($aConf['table']['prefix'] . 'trackers');
}
示例7: defaultData
function defaultData()
{
$oManager = new OX_Plugin_ComponentGroupManager();
if (!array_key_exists('testPlugin', $GLOBALS['_MAX']['CONF']['pluginGroupComponents'])) {
$oManager->disableComponentGroup('testPlugin');
}
$this->oManager->enableComponentGroup('testPlugin');
$oTestPluginTable = OA_Dal::factoryDO('testplugin_table');
if (!$oTestPluginTable) {
OA::debug('Failed to instantiate DataObject for testplugin_table');
return false;
}
$oTestPluginTable->myplugin_desc = 'Hello World';
$aSettings[0]['data'] = $oTestPluginTable->insert();
$aSettings[0]['section'] = 'myPlugin';
$aSettings[0]['key'] = 'english';
$oTestPluginTable->myplugin_desc = 'Hola Mundo';
$aSettings[1]['data'] = $oTestPluginTable->insert();
$aSettings[1]['section'] = 'myPlugin';
$aSettings[1]['key'] = 'spanish';
$oTestPluginTable->myplugin_desc = 'Look Simon, you\'re just making it up now';
$aSettings[2]['data'] = $oTestPluginTable->insert();
$aSettings[2]['section'] = 'myPlugin';
$aSettings[2]['key'] = 'russian';
$oManager->_registerSettings($aSettings);
$oManager->disableComponentGroup('testPlugin');
return true;
}
示例8: processBanners
function processBanners($commit = false)
{
$doBanners = OA_Dal::factoryDO('banners');
if (OA_INSTALLATION_STATUS === OA_INSTALLATION_STATUS_INSTALLED && OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
$doBanners->addReferenceFilter('agency', $agencyId = OA_Permission::getEntityId());
}
$doBanners->find();
$different = 0;
$same = 0;
$errors = array();
while ($doBanners->fetch()) {
// Rebuild filename
if ($doBanners->storagetype == 'sql' || $doBanners->storagetype == 'web') {
$doBanners->imageurl = '';
}
$GLOBALS['_MAX']['bannerrebuild']['errors'] = false;
if ($commit) {
$doBannersClone = clone $doBanners;
$doBannersClone->update();
$newCache = $doBannersClone->htmlcache;
} else {
$newCache = phpAds_getBannerCache($doBanners->toArray());
}
if (empty($GLOBALS['_MAX']['bannerrebuild']['errors'])) {
if ($doBanners->htmlcache != $newCache && $doBanners->storagetype == 'html') {
$different++;
} else {
$same++;
}
} else {
$errors[] = $doBanners->toArray();
}
}
return array('errors' => $errors, 'different' => $different, 'same' => $same);
}
示例9: testExecute
function testExecute()
{
Mock::generatePartial('OA_UpgradeLogger', $mockLogger = 'OA_UpgradeLogger' . rand(), array('logOnly', 'logError', 'log'));
$oLogger = new $mockLogger($this);
$oLogger->setReturnValue('logOnly', true);
$oLogger->setReturnValue('logError', true);
$oLogger->setReturnValue('log', true);
Mock::generatePartial('OA_Upgrade', $mockUpgrade = 'OA_Upgrade' . rand(), array('addPostUpgradeTask'));
$mockUpgrade = new $mockUpgrade($this);
$mockUpgrade->setReturnValue('addPostUpgradeTask', true);
$mockUpgrade->oLogger = $oLogger;
$mockUpgrade->oDBUpgrader = new OA_DB_Upgrade($oLogger);
$mockUpgrade->oDBUpgrader->oTable =& $this->oaTable;
// Run the upgrade
$postscript = new OA_UpgradePostscript_2_7_30_beta_rc5();
$ret = $postscript->execute(array(&$mockUpgrade));
$this->assertTrue($ret);
// Get the preference that we have inserted
$doPreferences = OA_Dal::factoryDO('preferences');
$doPreferences->preference_name = 'campaign_ecpm_enabled';
$doPreferences->account_type = 'MANAGER';
$doPreferences->find();
$numberPreferences = $doPreferences->getRowCount();
$this->assertEqual(1, $numberPreferences);
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:25,代码来源:postscript_openads_upgrade_2.7.30-beta-rc5.mig.test.php
示例10: testUpdate
/**
* Tests the timestamps are updated correctly.
*
* Test 1: Tests the current timestamp is inserted for a new image.
* Test 2: Tests the timestamp is updated when an image is updated.
*
*/
function testUpdate()
{
// Test 1
// Get the start time of the test
$start = time();
sleep(1);
// Insert an image
$doImages = OA_Dal::factoryDO('images');
$doImages->filename = 'foo.jpg';
$doImages->contents = '';
DataGenerator::generateOne($doImages);
// Get the image out of the DB
$doImages = OA_Dal::staticGetDO('images', 'filename', 'foo.jpg');
// Check the timestamp is > time at start of test and <= current time
// Deal with MySQL 4.0 timestamps
if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/', $doImages->t_stamp, $m)) {
$doImages->t_stamp = "{$m[1]}-{$m[2]}-{$m[3]} {$m[4]}:{$m[5]}:{$m[6]}";
}
$actual = strtotime($doImages->t_stamp);
$this->assertTrue($actual > $start && $actual <= time());
// Test 2
// Update the image
$doImages->contents = '1';
sleep(1);
$doImages->update();
// Get the image out of the DB
$doImages = OA_Dal::staticGetDO('images', 'filename', 'foo.jpg');
$oldTime = $actual;
// Deal with MySQL 4.0 timestamps
if (preg_match('/^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/', $doImages->t_stamp, $m)) {
$doImages->t_stamp = "{$m[1]}-{$m[2]}-{$m[3]} {$m[4]}:{$m[5]}:{$m[6]}";
}
$actual = strtotime($doImages->t_stamp);
$this->assertTrue($actual > $oldTime && $actual <= time());
}
示例11: addAdZoneAssoc
function addAdZoneAssoc($adId, $zoneId, $priority)
{
$doAd_zone_assoc = OA_Dal::factoryDO('ad_zone_assoc');
$doAd_zone_assoc->ad_id = $adId;
$doAd_zone_assoc->zone_id = $zoneId;
$doAd_zone_assoc->priority = $priority;
DataGenerator::generateOne($doAd_zone_assoc);
}
示例12: getAllAdvertisers
/**
* A method to retrieve a list of all advertiser names. Can be limited to
* just return the advertisers that are "owned" by an agency.
*
* @param string $listorder The column name to sort the agency names by. One of "name" or "id".
* @param string $orderdirection The sort oder for the sort column. One of "up" or "down".
* @param integer $agencyId Optional. The agency ID to limit results to.
* @return array
*
* @todo Consider removing order options (or making them optional)
*/
function getAllAdvertisers($listorder, $orderdirection, $agencyId = null)
{
$doClients = OA_Dal::factoryDO('clients');
if (!empty($agencyId) && is_numeric($agencyId)) {
$doClients->agencyid = $agencyId;
}
$doClients->addListOrderBy($listorder, $orderdirection);
return $doClients->getAll(array('clientname', 'an_adnetwork_id'), $indexWitkPk = true, $flatten = false);
}
示例13: idExists
private function idExists($tableName, $id)
{
$doObject = OA_Dal::factoryDO($tableName);
if (empty($id) || !($object = $doObject->get($id))) {
return false;
} else {
return true;
}
}
示例14: getEntity
protected function getEntity($entityTable, $entityId)
{
$do = OA_Dal::factoryDO($entityTable);
$aEntity = null;
if ($do->get($entityId)) {
$aEntity = $do->toArray();
}
return $aEntity;
}
示例15: testDuplicate
function testDuplicate()
{
// Insert a tracker with some default data.
$doTrackers = OA_Dal::factoryDO('trackers');
$doTrackers->trackername = 'foo';
$doTrackers->clientid = 1;
$doTrackers->clickwindow = 3600;
$doTrackers->status = 4;
$doTrackers->type = 1;
$trackerId = DataGenerator::generateOne($doTrackers, true);
// Insert a variable for the tracker
$doVariables = OA_Dal::factoryDO('variables');
$doVariables->trackerid = $trackerId;
$doVariables->name = 'bar';
$variableId = DataGenerator::generateOne($doVariables);
// Link the tracker to a campaign
$doCampaignTrackers = OA_Dal::factoryDO('campaigns_trackers');
$doCampaignTrackers->campaignid = 1;
$doCampaignTrackers->trackerid = $trackerId;
$campaignTrackerId = DataGenerator::generateOne($doCampaignTrackers);
// Duplicate the tracker
$doTrackers = OA_Dal::staticGetDO('trackers', $trackerId);
$newTrackerId = $doTrackers->duplicate();
$this->assertNotEmpty($newTrackerId);
// Get the two trackers
$doNewTrackers = OA_Dal::staticGetDO('trackers', $newTrackerId);
$this->assertTrue($doNewTrackers);
$doTrackers = OA_Dal::staticGetDO('trackers', $trackerId);
$this->assertTrue($doTrackers);
// Assert the trackers are not equal, excluding the primary key
$this->assertNotEqualDataObjects($this->stripKeys($doTrackers), $this->stripKeys($doNewTrackers));
// Assert the only difference in the trackers is their description
$doTrackers->trackername = $doNewTrackers->trackername = null;
$this->assertEqualDataObjects($this->stripKeys($doTrackers), $this->stripKeys($doNewTrackers));
// Get the two variables
$doNewVariables = OA_Dal::staticGetDO('variables', 'trackerid', $newTrackerId);
$this->assertTrue($doNewVariables);
$doVariables = OA_Dal::staticGetDO('variables', $variableId);
$this->assertTrue($doVariables);
// Assert the variables are not equal, excluding the primary key
$this->assertNotEqualDataObjects($this->stripKeys($doVariables), $this->stripKeys($doNewVariables));
// Assert the only difference in the variables is the trackers they are attached to
$doVariables->trackerid = $doNewVariables->trackerid = null;
$this->assertEqualDataObjects($this->stripKeys($doVariables), $this->stripKeys($doNewVariables));
// Get the two campaign tracker links
$doNewCampaignTrackers = OA_Dal::staticGetDO('campaigns_trackers', 'trackerid', $newTrackerId);
$this->assertTrue($doNewCampaignTrackers);
$doCampaignTrackers = OA_Dal::staticGetDO('campaigns_trackers', $campaignTrackerId);
$this->assertTrue($doCampaignTrackers);
// Assert the campaign trackers are not equal, excluding the primary key
$this->assertNotEqualDataObjects($this->stripKeys($doCampaignTrackers), $this->stripKeys($doNewCampaignTrackers));
// Assert the only difference in the campaign trackers is the trackers they are attached to
$doCampaignTrackers->trackerid = $doNewCampaignTrackers->trackerid = null;
$this->assertEqualDataObjects($this->stripKeys($doCampaignTrackers), $this->stripKeys($doNewCampaignTrackers));
DataGenerator::cleanUp(array('campaigns', 'campaigns_trackers', 'trackers', 'variables'));
}