/** * @return Gpf_SqlBuilder_SelectBuilder */ protected function createSelectBuilder() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Pap_Db_Table_Channels::ID, self::ID); $selectBuilder->select->add(Pap_Db_Table_Channels::NAME, self::VALUE); $selectBuilder->from->add(Pap_Db_Table_Channels::getName()); return $selectBuilder; }
protected function buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_DirectLinkUrls::getName(), "l"); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "l.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", "ch.channelid = l.channelid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), "b", "b.bannerid = l.bannerid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Campaigns::getName(), "c", "c.campaignid = l.campaignid"); }
public function loadChannels() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add(Pap_Db_Table_Channels::VALUE); $select->select->add(Pap_Db_Table_Channels::NAME); $select->from->add(Pap_Db_Table_Channels::getName()); $select->where->add(Pap_Db_Table_Channels::USER_ID, '=', Gpf_Session::getAuthUser()->getPapUserId()); $this->channels = array(); foreach ($select->getAllRowsIterator() as $row) { $this->channels[$row->get(Pap_Db_Table_Channels::VALUE)] = $row->get(Pap_Db_Table_Channels::NAME); } }
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'; }
function buildFrom() { $this->_selectBuilder->from->add(Pap_Db_Table_Transactions::getName(), "t"); $onCondition = "t.".Pap_Db_Table_Transactions::CAMPAIGN_ID." = 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", "t.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", "t.channel = ch.channelid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_CommissionTypes::getName(), "ct", "t.commtypeid = ct.commtypeid"); $this->_selectBuilder->from->addLeftJoin(Gpf_Db_Table_Currencies::getName(), 'cs', 't.originalcurrencyid = cs.currencyid'); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', 'b.bannerid = t.bannerid'); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_PayoutsHistory::getName(), 'ph', 'ph.'.Pap_Db_Table_PayoutsHistory::ID.' = t.'.Pap_Db_Table_Transactions::PAYOUTHISTORY_ID); }
protected function initChannelsSelect() { $this->channelsSelect = new Gpf_SqlBuilder_SelectBuilder(); $this->channelsSelect->select->add(Pap_Db_Table_Channels::ID); $this->channelsSelect->select->add(Pap_Db_Table_Channels::NAME); $this->channelsSelect->from->add(Pap_Db_Table_Channels::getName()); $this->channelsSelect->where->add(Pap_Db_Table_Channels::USER_ID, '=', Gpf_Session::getAuthUser()->getPapUserId()); }
protected function buildFrom() { $this->_selectBuilder->from->addSubselect($this->rawClicksSelect, "rc"); $onCondition = "rc.".Pap_Db_Table_RawClicks::CAMPAIGNID." = c.".Pap_Db_Table_Campaigns::ID; $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'c', $onCondition); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'b', "rc.bannerid = b.bannerid"); $this->_selectBuilder->from->addLeftJoin(Pap_Db_Table_Banners::getName(), 'pb', "rc.parentbannerid = pb.bannerid"); $this->_selectBuilder->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "rc.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', 'ch.channelid=rc.channel'); }
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')))); }