예제 #1
0
    private function countTotal() {

        $query = $this->buildQuery();

        $queryCount = JTheFactoryDatabase::getQuery();
        $queryCount->select('a.id');
        $queryCount->select(
                    'CASE a.auction_type
                        WHEN '.AUCTION_TYPE_PUBLIC.' THEN MAX(bids.bid_price)
                        WHEN '.AUCTION_TYPE_PRIVATE.' THEN a.initial_price
                        WHEN '.AUCTION_TYPE_BIN_ONLY.' THEN a.bin_price
                    END AS current_price'
                );

        if ($this->_searchWithCurrency) {
            $queryCount->select('curr.convert AS auctionCurrencyConversionRate');
        }

        foreach($query->get('from') as $from) {
            $queryCount->from($from['tableName'],$from['tableAlias']);
        }
        foreach($query->get('join') as $type=>$joins) {
            foreach($joins as $join) {
                $queryCount->join($type,$join['tableName'],$join['tableAlias'],$join['joinOn']);
            }
        }
        $queryCount->where($query->get('where'));
        $queryCount->group($query->get('group'));
        $queryCount->having($query->get('having'));

        $db = JFactory::getDbo();
        $db->setQuery( 'SELECT COUNT(1) FROM ('. (string) $queryCount .') AS allAuctions ');

        return $db->loadResult();
    }
예제 #2
0
    function getUserCountries()
    {
        $db= $this->getDbo();
        $query = JTheFactoryDatabase::getQuery();
        $profile = BidsHelperTools::getUserProfileObject();
        $field = $profile->getFilterField('country');
        $table = $profile->getFilterTable('country');

        
        $query->select("distinct `{$field}` country");
        $query->from($table);
        $query->where("`{$field}`<>'' and `{$field}` is not null");
        $db->setQuery((string)$query);
        return $db->loadObjectList();
        
    }
예제 #3
0
    private function countTotal() {

        $query = $this->buildQuery();

        $queryCount = JTheFactoryDatabase::getQuery();
        $queryCount->select('1');

        foreach($query->get('from') as $from) {
            $queryCount->from($from['tableName'],$from['tableAlias']);
        }
        foreach($query->get('join') as $type=>$joins) {
            foreach($joins as $join) {
                $queryCount->join($type,$join['tableName'],$join['tableAlias'],$join['joinOn']);
            }
        }
        $queryCount->where($query->get('where'));
        $queryCount->group($query->get('group'));
        $queryCount->having($query->get('having'));

        $db = JFactory::getDbo();
        $db->setQuery( 'SELECT COUNT(1) FROM ('. (string) $queryCount .') AS allAuctions ');

        return $db->loadResult();
    }