コード例 #1
0
 public function getCurrentAvgEurRate($targetcurrency, Gpf_DateTime_Range $range)
 {
     $sql = new Gpf_SqlBuilder_SelectBuilder();
     $sql->select->add('avg(' . Gpf_Db_Table_CurrencyRates::RATE . ')', Gpf_Db_Table_CurrencyRates::RATE);
     $sql->from->add(Gpf_Db_Table_CurrencyRates::getName());
     $sql->where->add(Gpf_Db_Table_CurrencyRates::SOURCE_CURRENCY, '=', 'EUR');
     $sql->where->add(Gpf_Db_Table_CurrencyRates::TARGET_CURRENCY, '=', $targetcurrency);
     $sql->where->add(Gpf_Db_Table_CurrencyRates::TYPE, '=', Gpf_Db_CurrencyRate::TYPE_DAILY);
     $dateCondition = new Gpf_SqlBuilder_CompoundWhereCondition();
     $coumpoundCondWithin = new Gpf_SqlBuilder_CompoundWhereCondition();
     $coumpoundCondWithin->add(Gpf_Db_Table_CurrencyRates::VALID_FROM, '>=', $range->getFrom()->toDateTime());
     $coumpoundCondWithin->add(Gpf_Db_Table_CurrencyRates::VALID_TO, '<=', $range->getTo()->toDateTime());
     $dateCondition->addCondition($coumpoundCondWithin, 'OR');
     $coumpoundCondBefore = new Gpf_SqlBuilder_CompoundWhereCondition();
     $coumpoundCondBefore->add(Gpf_Db_Table_CurrencyRates::VALID_FROM, '<=', $range->getFrom()->toDateTime());
     $coumpoundCondBefore->add(Gpf_Db_Table_CurrencyRates::VALID_TO, '>=', $range->getFrom()->toDateTime());
     $dateCondition->addCondition($coumpoundCondBefore, 'OR');
     $coumpoundCondAfter = new Gpf_SqlBuilder_CompoundWhereCondition();
     $coumpoundCondAfter->add(Gpf_Db_Table_CurrencyRates::VALID_FROM, '<=', $range->getTo()->toDateTime());
     $coumpoundCondAfter->add(Gpf_Db_Table_CurrencyRates::VALID_TO, '>=', $range->getTo()->toDateTime());
     $dateCondition->addCondition($coumpoundCondAfter, 'OR');
     $sql->where->addCondition($dateCondition);
     Gpf_Log::debug($sql->toString());
     Gpf_Log::debug('Avg rate: ' . $sql->getOneRow()->get(Gpf_Db_Table_CurrencyRates::RATE));
     return $sql->getOneRow()->get(Gpf_Db_Table_CurrencyRates::RATE);
 }
コード例 #2
0
 public function computeCommissions() {
     $this->sqlBuilder = new Gpf_SqlBuilder_SelectBuilder();
     $this->sqlBuilder->select->add("SUM(".self::TRANSACTION_ALIAS.'.'.Pap_Db_Table_Transactions::COMMISSION.")", self::VALUE);
     $this->buildSql();
     $record = $this->sqlBuilder->getOneRow();
     return $record->get(self::VALUE);
 }
コード例 #3
0
    /**
     * @service pay_affiliate read
     * @param $data
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->add("au.username","userName");
        $select->select->add("au.firstname","firstName");
        $select->select->add("au.lastname","lastname");
        $select->select->add("SUM(t.".Pap_Db_Table_Transactions::COMMISSION.")", "payout");
        $select->select->add("pu.".Pap_Db_Table_Users::MINIMUM_PAYOUT, "minimumPayout");
        $select->select->add("IFNULL(po.".Gpf_Db_Table_FieldGroups::NAME.", 'undefined')", "payoutMethod");
        $select->from->add(Pap_Db_Table_Transactions::getName(), "t");
        $select->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "t.userid = pu.userid");
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
        $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
        $select->groupBy->add("t.".Pap_Db_Table_Transactions::USER_ID);
        $select->from->addLeftJoin(Gpf_Db_Table_FieldGroups::getName(), "po", "pu.payoutoptionid = po.fieldgroupid");
        $select->where->add("t.".Pap_Db_Table_Transactions::USER_ID, "=", $params->get("id"));
        $row = $select->getOneRow();

        $data->setValue("userName", $row->get("userName"));
        $data->setValue("firstName", $row->get("firstName"));
        $data->setValue("lastname", $row->get("lastname"));
        $data->setValue("payout", $row->get("payout"));
        $data->setValue("minimumPayout", $row->get("minimumPayout"));
        $data->setValue("payoutMethod", $row->get("payoutMethod"));

        return $data;
    }
コード例 #4
0
 public function execute() {
     $task = new Gpf_Db_Task();
     $task->setClassName('Gpf_Mail_OutboxRunner');
     $task->loadFromData(array(Gpf_Db_Table_Tasks::CLASSNAME));
     
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Gpf_Db_Table_MailOutbox::ID);
     $select->from->add(Gpf_Db_Table_MailOutbox::getName());
     $select->orderBy->add(Gpf_Db_Table_MailOutbox::ID);
     $select->limit->set(0,1);
     try {
     	$row = $select->getOneRow();
     	$begining = $row->get(Gpf_Db_Table_MailOutbox::ID);
     } catch (Gpf_Exception $e) {
     	$begining = 1;
     }
     
     try {
         $task->load();
         $task->setParams($begining);
         $task->setWorkingAreaFrom($begining);   
         $task->setWorkingAreaTo(Gpf_Mail_OutboxRunner::MAX_MAIL_WORKERS_COUNT);
         $task->update(array(Gpf_Db_Table_Tasks::WORKING_AREA_FROM, Gpf_Db_Table_Tasks::WORKING_AREA_TO, Gpf_Db_Table_Tasks::PARAMS));
     } catch (Gpf_Exception $e) {
         throw new Gpf_Exception('Cannot update Gpf_Mail_OutboxRunner task to paralel version');
     }
 }
コード例 #5
0
    /**
     *
     * @service affiliate_stats read
     * @param $data
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);
        $filters = $data->getFilters();
		$statsParams = new Pap_Stats_Params();
		$statsParams->initFrom($filters);				
		$transactions = new Pap_Stats_Transactions($statsParams);                

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->from->add(Pap_Db_Table_Users::getName(), "pu");
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "gu.accountuserid = pu.accountuserid");
        $select->select->add("SUM(IF(pu.rtype = '". Pap_Application::ROLETYPE_AFFILIATE ."', 1, 0))", "countAffiliates");
        $select->select->add("SUM(IF(gu.rstatus = 'A', 1, 0))", "approvedAffiliates");
        $select->select->add("SUM(IF(gu.rstatus = 'P', 1, 0))", "pendingAffiliates");
        $filters->addTo($select->where);
        $select->where->add("pu.".Pap_Db_Table_Users::TYPE, "=", Pap_Application::ROLETYPE_AFFILIATE);        
        $row = $select->getOneRow();

        $data->setValue("countAffiliates", $this->checkNullValue($row->get("countAffiliates")));
        $data->setValue("approvedAffiliates", $this->checkNullValue($row->get("approvedAffiliates")));
        $data->setValue("pendingAffiliates", $this->checkNullValue($row->get("pendingAffiliates")));
        $data->setValue("totalSales", $transactions->getTotalCost()->getAll());
        $data->setValue("approvedCommissions", $transactions->getCommission()->getApproved());
        $data->setValue("pendingCommissions", $transactions->getCommission()->getPending());

        return $data;
    }
コード例 #6
0
 private function isMasterMerchant($authId) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Gpf_Db_Table_Users::ROLEID);
     $select->from->add(Gpf_Db_Table_AuthUsers::getName(), 'au');
     $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'u', 'au.' . Gpf_Db_Table_AuthUsers::ID . '=u.' . Gpf_Db_Table_Users::AUTHID);
     $select->where->add('au.' . Gpf_Db_Table_AuthUsers::ID, '=', $authId);
     return $select->getOneRow()->get(Gpf_Db_Table_Users::ROLEID) == Pap_Application::DEFAULT_ROLE_MERCHANT;
 }
コード例 #7
0
 private function getLogsCount()
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('count(*)', 'numrows');
     $select->from->add(Gpf_Db_Table_Logs::getName());
     $row = $select->getOneRow();
     return $row->get('numrows');
 }
コード例 #8
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 protected function getChildAffiliateTransactionsCount($userId){
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('count('.Pap_Db_Table_Transactions::USER_ID.')','numberOfTransactions');
     $select->from->add(Pap_Db_Table_Transactions::getName());
     $select->where->add(Pap_Db_Table_Transactions::USER_ID,'=',$userId);
     $row = $select->getOneRow();
     return $row->get('numberOfTransactions');
 }
コード例 #9
0
 private function getOldestEntry($table) {
     $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
     $selectBuilder->select->add('day');
     $selectBuilder->from->add($table);
     $selectBuilder->orderBy->add('day');
     $selectBuilder->limit->set(0, 1);
     $row = $selectBuilder->getOneRow();
     return $row->get('day');
 }
コード例 #10
0
 /**
  * @param String $code
  * @return String $name
  */
 public static function getNameFromCode($code)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Gpf_Db_Table_ImportExports::NAME);
     $select->from->add(Gpf_Db_Table_ImportExports::getName());
     $select->where->add(Gpf_Db_Table_ImportExports::CODE, "=", $code);
     $className = $select->getOneRow();
     return $className->get(Gpf_Db_Table_ImportExports::NAME);
 }
コード例 #11
0
 /**
  * Returns banner object
  *
  * @throws Gpf_DbEngine_NoRowException
  * @param string $bannerId banner ID
  * @return Pap_Common_Banner
  */
 public function getBanner($bannerId) {
     if ($bannerId == '') {
         throw new Pap_Common_Banner_NotFound($bannerId);
     }
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->from->add(Pap_Db_Table_Banners::getName());
     $select->select->addAll(Pap_Db_Table_Banners::getInstance());
     $select->where->add(Pap_Db_Table_Banners::ID, '=', $bannerId);
     return $this->getBannerFromRecord($select->getOneRow());
 }
コード例 #12
0
	public function getCount() {
    	$selectBuilder = $this->getSelect();
        $selectBuilder->select->add('i.affiliateid', 'affiliateid');

	    $selectBuilderCount = new Gpf_SqlBuilder_SelectBuilder();
	    $selectBuilderCount->select->add('count(*)', 'count');
	    $selectBuilderCount->from->addSubselect($selectBuilder, 'sub');
	    $row = $selectBuilderCount->getOneRow();
        return $row->get('count');
	}
コード例 #13
0
ファイル: Base.class.php プロジェクト: AmineCherrai/rostanvo
 private function typeExists($type)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('count(' . Gpf_Db_Table_HierarchicalDataNodes::ID . ') as cnt');
     $select->from->add(Gpf_Db_Table_HierarchicalDataNodes::getName());
     $select->where->add(Gpf_Db_Table_HierarchicalDataNodes::TYPE, '=', $type);
     $row = $select->getOneRow();
     if ($row->get('cnt') > 0) {
         return true;
     }
     return false;
 }
コード例 #14
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 protected function getUserId($username) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('pu.'.Pap_Db_Table_Users::ID, 'id');
     $select->from->add(Pap_Db_Table_Users::getName(), 'pu');
     $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu',
         'pu.'.Pap_Db_Table_Users::ACCOUNTUSERID.'=gu.'.Gpf_Db_Table_Users::ID);
     $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au',
         'gu.'.Gpf_Db_Table_Users::AUTHID.'=au.'.Gpf_Db_Table_AuthUsers::ID);
     $select->where->add('pu.'.Pap_Db_Table_Users::TYPE, '=', Pap_Application::ROLETYPE_AFFILIATE);
     $select->where->add('pu.'.Pap_Db_Table_Users::DELETED, '<>', Gpf::YES);
     $select->where->add('au.'.Gpf_Db_Table_AuthUsers::USERNAME, '=', $username);
     return $select->getOneRow()->get('id');
 }
 protected function loadRow(Gpf_DbEngine_Row $row) {
     $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
     $selectBuilder->from->add($row->getTable()->name());
     $selectBuilder->select->addAll($row->getTable());
     foreach ($this->uniqueColumnNames as $columnName=>$value) {
         if ($value === false) {
             $selectBuilder->where->add($columnName,'=',$row->get($columnName));
             continue;
         }
         $selectBuilder->where->add($columnName,'=',$value);
     }
     return $selectBuilder->getOneRow();
 }
コード例 #16
0
ファイル: User.class.php プロジェクト: AmineCherrai/rostanvo
 public function loadByRoleType($roleType, $application)
 {
     $query = new Gpf_SqlBuilder_SelectBuilder();
     $query->select->addAll(Gpf_Db_Table_Users::getInstance(), 'u');
     $query->from->add(Gpf_Db_Table_Users::getName(), "u");
     $query->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), "r", "r.roleid = u.roleid");
     $query->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(), "a", "u.accountid = a.accountid");
     $query->where->add('u.authid', '=', $this->getAuthId());
     $query->where->add('u.accountid', '=', $this->getAccountId());
     $query->where->add('a.application', '=', $application);
     $query->where->add('r.roletype', '=', $roleType);
     $record = $query->getOneRow();
     $this->fillFromRecord($record);
 }
コード例 #17
0
 public function onActivate() {
     try {
         $sql = new Gpf_SqlBuilder_SelectBuilder();
         $sql->select->add('count(*)', 'num_tables');
         $sql->from->add('INFORMATION_SCHEMA.TABLES');
         $sql->where->add("TABLE_SCHEMA", "=", Gpf_Settings::get(Gpf_Settings_Gpf::DB_DATABASE));
         $num_tables = $sql->getOneRow()->get('num_tables');
         if ($num_tables < 10) {
             throw new Gpf_Exception('Tables is less than 10 - something is not correct');
         }
     } catch (Gpf_Exception $e) {
         throw new Gpf_Exception($this->_('Failed to activate plugin, database user %s has no rights to read information_schema.tables system database.', Gpf_Settings::get(Gpf_Settings_Gpf::DB_USERNAME)));
     }
 }
コード例 #18
0
	private function getPaidData(Gpf_Rpc_FilterCollection $filters) {
		$select = new Gpf_SqlBuilder_SelectBuilder();
		$select->select->add("SUM(amount)", "paid");
		$select->from->add(Pap_Db_Table_Payouts::getName(), "p");
		$select->from->addInnerJoin(Pap_Db_Table_PayoutsHistory::getName(), "ph", "p.payouthistoryid = ph.payouthistoryid");
		$filters->addTo($select->where);		
		
		Gpf_Plugins_Engine::extensionPoint('AffiliateNetwork.modifyWhere', 
        new Gpf_Common_SelectBuilderCompoundRecord($select, new Gpf_Data_Record(array('columnPrefix'), array('ph'))));
		
		$row = $select->getOneRow();

		return $this->checkNullValue($row->get("paid"));
	}
コード例 #19
0
    /**
     * @throws Gpf_DbEngine_NoRowException
     * @return Pap_Common_User
     */
    public function getMerchant() {
    	$select = new Gpf_SqlBuilder_SelectBuilder();
		$select->select->add('pu.'.Pap_Db_Table_Users::ID, Pap_Db_Table_Users::ID);
		$select->from->add(Pap_Db_Table_Users::getName(), 'pu');
		$select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu',
		'pu.'.Pap_Db_Table_Users::ACCOUNTUSERID.'=gu.'.Gpf_Db_Table_Users::ID);
		$select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au',
		'au.'.Gpf_Db_Table_AuthUsers::ID.'=gu.'.Gpf_Db_Table_Users::AUTHID);
		$select->where->add('au.'.Gpf_Db_Table_AuthUsers::USERNAME, '=', $this->getEmail());
		$select->where->add('gu.'.Gpf_Db_Table_Users::ACCOUNTID, '=', $this->getId());
		$merchantId = $select->getOneRow()->get(Pap_Db_Table_Users::ID);
		
		return Pap_Merchants_User::getUserById($merchantId);
    }
コード例 #20
0
    /**
     *
     * @return Pap_Common_Transaction
     */
    protected function getParentTransaction($futurePayId) {
        $select = new Gpf_SqlBuilder_SelectBuilder();
         
        $select->select->addAll(Pap_Db_Table_Transactions::getInstance());
        $select->from->add(Pap_Db_Table_Transactions::getName());
        $select->where->add(Pap_Db_Table_Transactions::DATA5, "=", $futurePayId);

        $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD));
        $select->where->add(Pap_Db_Table_Transactions::TIER, "=", "1");
         
        $select->limit->set(0, 1);
        $t = new Pap_Common_Transaction();
        $t->fillFromRecord($select->getOneRow());

        return $t;
    }
コード例 #21
0
    protected function isExtraBonusExists() {
        $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
        $selectBuilder->select->add('count(*)', 'cnt');
        $selectBuilder->from->add(Pap_Db_Table_Transactions::getName());

        $selectBuilder->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', Pap_Db_Transaction::TYPE_EXTRA_BONUS);
        $selectBuilder->where->add(Pap_Db_Table_Transactions::USER_ID, '=', $this->getCurrentUserId());
        $selectBuilder->where->add(Pap_Db_Table_Transactions::CAMPAIGN_ID, '=', $this->transaction->getCampaignId());
        $selectBuilder->where->add(Pap_Db_Table_Transactions::DATA1, '=', $this->rule->getId());
        $selectBuilder->where->add(Pap_Db_Table_Transactions::DATA2, '=', $this->getToDateRange());

        $row = $selectBuilder->getOneRow();
        if ($row->get('cnt') > 0) {
            return true;
        }
        return false;
    }
コード例 #22
0
    public function execute() {
        $this->createDatabase()->execute('ALTER TABLE  `qu_pap_campaigns` ADD  `longdescription` TEXT NULL');

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->addAll(Gpf_Db_Table_Settings::getInstance());
        $select->from->add(Gpf_Db_Table_Settings::getName());
        $select->where->add(Gpf_Db_Table_Settings::NAME, '=', 'default_campaign_id');
        try {
            $result = $select->getOneRow();
            $previousDefaultCampaign = $result->get(Gpf_Db_Table_Settings::VALUE);
            $campaignForm = new Pap_Merchants_Campaign_CampaignForm();
            $campaignForm->setCampaignDefault($previousDefaultCampaign);
        } catch (Gpf_DbEngine_NoRowException $e) {
        }

        $this->createDatabase()->execute('ALTER TABLE `qu_pap_campaigns` DROP `longdescription`');
    }
コード例 #23
0
 /**
  * Validate Db_Row
  *
  * @param Gpf_DbEngine_Row $row
  * @throws Gpf_DbEngine_Row_ConstraintException
  */
 public function validate(Gpf_DbEngine_Row $row)
 {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('COUNT(*)', 'cnt');
     $select->from->add($row->getTable()->name());
     foreach ($row->getPrimaryColumns() as $primaryColumn) {
         $select->where->add($primaryColumn->getName(), '<>', $row->get($primaryColumn->getName()));
     }
     $conditionNotEqalColumns = new Gpf_SqlBuilder_CompoundWhereCondition();
     foreach ($this->columnsNotEqualNames as $columnNotEqualName) {
         $conditionNotEqalColumns->add($columnNotEqualName, '=', $row->get($this->columnName), 'OR');
     }
     $select->where->addCondition($conditionNotEqalColumns);
     $select->limit->set(0, 1);
     if ($select->getOneRow()->get('cnt') > 0) {
         $this->throwException();
     }
 }
コード例 #24
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 /**
  * @param Pap_Contexts_Tracking $context
  * @return boolean
  */
 private function isInCookieLifetimeLimit(Pap_Contexts_Tracking $context) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Pap_Db_Table_Transactions::DATE_INSERTED);
     $select->from->add(Pap_Db_Table_Transactions::getName());
     $select->where->add(Pap_Db_Table_Transactions::DATA1, '=', $this->getIdentifier($context));
     $select->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', Pap_Db_Transaction::TYPE_SALE);
     $select->orderBy->add(Pap_Db_Table_Transactions::DATE_INSERTED);
     $select->limit->set(0, 1);
     try {
         $firstSale = $select->getOneRow()->get(Pap_Db_Table_Transactions::DATE_INSERTED);
         $cookieLifeTime = Pap_Tracking_Cookie::getCookieLifeTimeInDays($context);
         if (Gpf_Common_DateUtils::getDifference($firstSale, Gpf_Common_DateUtils::getDateTime(time()), 'day') > $cookieLifeTime) {
             $context->debug('    Transaction is not in cookie limit. Date of first transaction: ' . $firstSale . ' is not in cookie limit: ' . $cookieLifeTime . ' days.');
             return false;
         }
     } catch (Gpf_DbEngine_NoRowException $e) {
     }
     return true;
 }
コード例 #25
0
 private function generateDefaultValue($userId) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('MAX(CAST(SUBSTR('.Pap_Db_Table_Channels::VALUE.', 5) AS UNSIGNED))', 'max');
     $select->from->add(Pap_Db_Table_Channels::getName());
     $select->where->add(Pap_Db_Table_Channels::VALUE, 'like', 'code%');
     $select->where->add(Pap_Db_Table_Channels::USER_ID, '=', $userId);
     try {
         $result = $select->getOneRow();
         $max = $result->get('max')+1;
     } catch (Gpf_DbEngine_NoRowException $e) {
         $max = 1;
     } catch (Gpf_DbEngine_TooManyRowsException $e) {
         Gpf_Log::error('Database not in consistent state. Error in qu_pap_channels.');
     }
     if (isset($max)) {
         return 'code'.$max;
     }
     return 'code';
 }
コード例 #26
0
    /**
     * @throws Gpf_DbEngine_TooManyRowsException
     * @throws Gpf_DbEngine_NoRowException
     * @param string $categoryId
     * @return Gpf_Data_Record
     */
    private function getCategoryData($categoryId) {
        $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();

        $selectBuilder->select->add(Pap_Db_Table_BannersCategories::DESCRIPTION, Pap_Db_Table_BannersCategories::DESCRIPTION, 'c');
        $selectBuilder->select->add(Pap_Db_Table_BannersCategories::CATEGORYID, Pap_Db_Table_BannersCategories::CATEGORYID, 'c');
        $selectBuilder->select->add(Gpf_Db_Table_HierarchicalDataNodes::NAME, Gpf_Db_Table_HierarchicalDataNodes::NAME, 'h');
        $selectBuilder->select->add(Gpf_Db_Table_HierarchicalDataNodes::STATE, 'visible', 'h');

        $selectBuilder->from->add(Gpf_Db_Table_HierarchicalDataNodes::getName(), "h");
        $selectBuilder->from->addLeftJoin(Pap_Db_Table_BannersCategories::getName(), "c",
            "h.".Gpf_Db_Table_HierarchicalDataNodes::CODE." = c.".Pap_Db_Table_BannersCategories::CATEGORYID);

        $selectBuilder->where->add(Gpf_Db_Table_HierarchicalDataNodes::TYPE, '=', Pap_Features_BannersCategories_Main::BANNERS_CATEGORIES_HIERARCHICAL_DATE_TYPE);
        $selectBuilder->where->add(Pap_Db_Table_BannersCategories::CATEGORYID,'=',$categoryId);

        $row = $selectBuilder->getOneRow();
        	
        return $row;
    }
コード例 #27
0
    /**
     * @throws Gpf_DbEngine_NoRowException
     * @return Pap_Common_Transcation
     */
    protected function getClonedTransactionFromDb(Pap_Common_Transaction $transaction) {
        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->addAll(Pap_Db_Table_Transactions::getInstance());
        $select->from->add(Pap_Db_Table_Transactions::getName());
        $select->where->add(Pap_Db_Table_Transactions::USER_ID, '=', $transaction->getUserId());
        $select->where->add(Pap_Db_Table_Transactions::CAMPAIGN_ID, '=', $transaction->getCampaignId());
        $select->where->add(Pap_Db_Table_Transactions::BANNER_ID, '=', $transaction->getBannerId());
        $select->where->add(Pap_Db_Table_Transactions::CHANNEL, '=', $transaction->getChannel());
        $select->where->add(Pap_Db_Table_Transactions::R_STATUS, '=', $transaction->getStatus());
        $select->where->add(Pap_Db_Table_Transactions::TIER, '=', $transaction->getTier());
        $select->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', $transaction->getType());
        $select->where->add(Pap_Db_Table_Transactions::COUNTRY_CODE, '=', $transaction->getCountryCode());
        $select->where->add(Pap_Db_Table_Transactions::PAYOUT_STATUS, '=', $transaction->getPayoutStatus());
        $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, 'like', $this->dateTimeToDate($transaction->getDateInserted()).'%');
        $select->orderBy->add(Pap_Db_Table_Transactions::DATE_INSERTED, false);
        $select->limit->set(0, 1);

        $transaction = new Pap_Common_Transaction();
        $transaction->fillFromRecord($select->getOneRow());
        return $transaction;
    }
コード例 #28
0
 /**
  * Validate Db_Row
  *
  * @param Gpf_DbEngine_Row $row
  * @throws Gpf_DbEngine_Row_ConstraintException
  */
 public function validate(Gpf_DbEngine_Row $row)
 {
     $role = new Gpf_Db_Role();
     $role->setId($row->getRoleId());
     $role->load();
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add('r.' . Gpf_Db_Table_Roles::TYPE);
     $select->from->add(Gpf_Db_Table_Users::getName(), 'u');
     $select->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), 'r', 'u.' . Gpf_Db_Table_Users::ROLEID . '=r.' . Gpf_Db_Table_Roles::ID);
     $select->where->add('u.' . Gpf_Db_Table_Users::AUTHID, '=', $row->getAuthId());
     $select->where->add('u.' . Gpf_Db_Table_Users::ACCOUNTID, '=', $row->getAccountId());
     $select->where->add('r.' . Gpf_Db_Table_Roles::TYPE, '=', $role->getRoleType());
     $select->where->add('u.' . Gpf_Db_Table_Users::ID, '<>', $row->getPrimaryKeyValue());
     try {
         $select->getOneRow();
     } catch (Gpf_DbEngine_NoRowException $e) {
         return;
     } catch (Gpf_DbEngine_TooManyRowsException $e) {
     }
     throw new Gpf_DbEngine_Row_ConstraintException('username', $this->_('Selected username already exists'));
 }
コード例 #29
0
    public function execute() {
        $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
        $selectBuilder->select->add(Pap_Db_Table_CommissionTypes::ID);
        $selectBuilder->from->add(Pap_Db_Table_CommissionTypes::getName());
        $selectBuilder->where->add(Pap_Db_Table_CommissionTypes::TYPE, '=', Pap_Common_Constants::TYPE_REFERRAL);
        try {
            $selectBuilder->getOneRow();
            return;
        } catch (Gpf_Exception $e) {
        }

        $insert = new Gpf_SqlBuilder_InsertBuilder();
        $insert->setTable(Pap_Db_Table_CommissionTypes::getInstance());
        $insert->add(Pap_Db_Table_CommissionTypes::ID, 'refercom');
        $insert->add(Pap_Db_Table_CommissionTypes::TYPE, Pap_Common_Constants::TYPE_REFERRAL);
        $insert->add(Pap_Db_Table_CommissionTypes::STATUS, Pap_Db_CommissionType::STATUS_ENABLED);
        $insert->add(Pap_Db_Table_CommissionTypes::APPROVAL, Pap_Db_CommissionType::APPROVAL_AUTOMATIC);
        $insert->add(Pap_Db_Table_CommissionTypes::ZEROORDERSCOMMISSION, Gpf::NO);
        try {
            $insert->execute();
        } catch (Exception $e) {
        }
    }
コード例 #30
0
 public static function getStatus($campaignId, $userId) {
     $select = new Gpf_SqlBuilder_SelectBuilder();
     $select->select->add(Pap_Db_Table_UserInCommissionGroup::STATUS);
     $select->from->add(Pap_Db_Table_CommissionGroups::getName(), 'cg');
     $select->from->addInnerJoin(Pap_Db_Table_UserInCommissionGroup::getName(), 'ucg',
         'cg.'.Pap_Db_Table_CommissionGroups::ID.'=ucg.'.Pap_Db_Table_UserInCommissionGroup::COMMISSION_GROUP_ID);
     $select->where->add('cg.'.Pap_Db_Table_CommissionGroups::CAMPAIGN_ID, '=', $campaignId);
     $select->where->add('ucg.'.Pap_Db_Table_UserInCommissionGroup::USER_ID, '=', $userId);
     $row = $select->getOneRow();
     
     return $row->get(Pap_Db_Table_UserInCommissionGroup::STATUS);
 }