예제 #1
0
 public function getStatsSelect(Pap_Stats_StatsSelectContext $statsSelectContext) {
     if ($statsSelectContext->getGroupColumn() == Pap_Db_Table_Banners::ID) {
         $select = new Gpf_SqlBuilder_SelectBuilder();
         $select->cloneObj($statsSelectContext->getSelectBuilder());
         $select->select->replaceColumn($statsSelectContext->getGroupColumnAlias(), Pap_Db_Table_BannersInRotators::PARENT_BANNER_ID, $statsSelectContext->getGroupColumnAlias());
         $select->groupBy->removeByName(Pap_Db_Table_Banners::ID);
         $select->groupBy->add(Pap_Db_Table_BannersInRotators::PARENT_BANNER_ID);
         $statsSelectContext->getUnionBuilder()->addSelect($select);
     }
 }
    public function processResult(Gpf_SqlBuilder_SelectBuilder $selectBuilder) {
        $innerSelect = new Gpf_SqlBuilder_SelectBuilder();
        $innerSelect->cloneObj($selectBuilder);

        $selectBuilder->select = new Gpf_SqlBuilder_SelectClause();
        $selectBuilder->from = new Gpf_SqlBuilder_FromClause();
        $selectBuilder->where = new Gpf_SqlBuilder_WhereClause();
        $selectBuilder->groupBy = new Gpf_SqlBuilder_GroupByClause();
        $selectBuilder->orderBy = new Gpf_SqlBuilder_OrderByClause();
        $selectBuilder->limit = new Gpf_SqlBuilder_LimitClause();
        $selectBuilder->having = new Gpf_SqlBuilder_HavingClause();

        $selectBuilder->select->add("s.status");
        $selectBuilder->select->add("s.payoutstatus");
        $selectBuilder->select->add("sum(s.cnt)", "cnt");
        $selectBuilder->select->add("sum(s.commission)", "commission");
        $selectBuilder->select->add("sum(s.totalcost)", "totalcost");
        $selectBuilder->from->addSubselect($innerSelect, 's');
        $selectBuilder->groupBy->add("s.status");
        $selectBuilder->groupBy->add("s.payoutstatus");
    }
예제 #3
0
    /**
     * HACK: mosso MySQL servers can not handle large result sets so the select has to be splitted
     */
    protected function doMossoHack(Gpf_DbEngine_Table $primaryTable, $primaryTableAlias, $primaryColumnName) {
        $orderSelect = new Gpf_SqlBuilder_SelectBuilder();
        $orderSelect->cloneObj($this->_selectBuilder);
        $orderSelect->select = new Gpf_SqlBuilder_SelectClause();
        $orderSelect->select->add($primaryTableAlias.'.'.$primaryColumnName, 'idCol');
        foreach ($orderSelect->orderBy->getAllOrderColumns() as $orderColumns) {
            $dataColumn = $this->dataColumns[$orderColumns->getName()];
            $orderSelect->select->add($dataColumn->getName(), $dataColumn->getId());
        }

        $this->_selectBuilder->from = new Gpf_SqlBuilder_FromClause();
        $this->_selectBuilder->from->addSubselect($orderSelect, 'ors');
        $this->_selectBuilder->from->addInnerJoin($primaryTable->name(), $primaryTableAlias,
        $primaryTableAlias.'.'.$primaryColumnName.'=ors.idCol');
        $i = 0;
        foreach ($orderSelect->from->getAllFroms() as $fromClause) {
            if ($i++ == 0) {
                continue;
            }
            $this->_selectBuilder->from->addClause($fromClause);
        }
        $this->_selectBuilder->limit = new Gpf_SqlBuilder_LimitClause();
    }
예제 #4
0
	protected function computeCount() {
		$countSelect = new Gpf_SqlBuilder_SelectBuilder();
		$countSelect->cloneObj($this->rawClicksSelect);
		$countSelect->select = new Gpf_SqlBuilder_SelectClause();
		$countSelect->select->add('count(*)', 'count');
		$countSelect->orderBy = new Gpf_SqlBuilder_OrderByClause();
		$this->_count = $countSelect->getOneRow()->get('count');
	}