private function deleteVisitorAffiliates() {
     $delete = new Gpf_SqlBuilder_DeleteBuilder();
     $delete->from->add(Pap_Db_Table_VisitorAffiliates::getName());
     $delete->where->add(Pap_Db_Table_VisitorAffiliates::VALIDTO,'<',Gpf_Common_DateUtils::now());
     $delete->where->add(Pap_Db_Table_VisitorAffiliates::VALIDTO,'!=',null);
     $delete->limit->set('',$this->deleteLimit);
     $statement = $delete->delete();
     return $statement->affectedRows()>0;
 }
Beispiel #2
0
 private function updateValidToDate($lifetime, $campaignId = null) {
     $update = new Gpf_SqlBuilder_UpdateBuilder();
     $update->from->add(Pap_Db_Table_VisitorAffiliates::getName());
     $update->set->add(Pap_Db_Table_VisitorAffiliates::VALIDTO,
         'DATE_ADD('.Pap_Db_Table_VisitorAffiliates::DATEVISIT.', INTERVAL '.$lifetime.' DAY)', false);
     $update->where->add(Pap_Db_Table_VisitorAffiliates::VALIDTO, 'is', 'NULL', 'AND', false);
     if ($campaignId !== null) {
         $update->where->add(Pap_Db_Table_VisitorAffiliates::CAMPAIGNID, '=', $campaignId);
     }
     $update->update();
 }
 protected function init() {
     $this->setTable(Pap_Db_Table_VisitorAffiliates::getInstance());
     parent::init();
 }
	private function deleteVisitorAffiliatesFromDb() {
		if (count($this->removeVisitorAffiliateIds) == 0) {
			return;
		}

		$deleteBuilder = new Gpf_SqlBuilder_DeleteBuilder();
		$deleteBuilder->from->add(Pap_Db_Table_VisitorAffiliates::getName());
		foreach ($this->removeVisitorAffiliateIds as $id) {
			$deleteBuilder->where->add(Pap_Db_Table_VisitorAffiliates::ID, '=', $id, 'OR');
		}
		$deleteBuilder->execute();
	}
    protected function isNewVisitor($visitorId) {
        if (isset($this->visitorCache[$visitorId])) {
            return false;
        }
        $this->visitorCache[$visitorId] = true;

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->from->add(Pap_Db_Table_VisitorAffiliates::getName());
        $select->select->add(Pap_Db_Table_VisitorAffiliates::VISITORID);
        $select->where->add(Pap_Db_Table_VisitorAffiliates::VISITORID, '=', $visitorId);
        $select->limit->set(0, 1);
        try {
            $select->getOneRow();
            return false;
        } catch (Gpf_DbEngine_NoRowException $e) {
            return true;
        }
    }
 public static function getInstance() {
     if(self::$instance === null) {
         self::$instance = new self;
     }
     return self::$instance;
 }
 protected function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_VisitorAffiliates::getName(), "va");
     $onCondition = "va.".Pap_Db_Table_VisitorAffiliates::CAMPAIGNID." = c.".Pap_Db_Table_Campaigns::ID;
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), 'c', $onCondition);
     $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "va.userid = pu.userid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Channels::getName(), "ch", "va.channelid = ch.channelid");
     $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', 'b.bannerid = va.bannerid');
     Gpf_Plugins_Engine::extensionPoint('AffiliateNetwork.modifyFrom',
     new Gpf_Common_SelectBuilderCompoundRecord($this->_selectBuilder,
     new Gpf_Data_Record(array('joinedAlias', 'onJoinAlias'), array('a', 'va'))));
 }