library/Garp/Browsebox/Filter/Related.php
public function fetchMaxChunks(Zend_Db_Select $select, Garp_Browsebox $browsebox) {
        if (!empty($this->_params)) {
            $model = $browsebox->getModel();
            $filterModel = new $this->_config['model']();
            $bindingModel = new $this->_config['bindingOptions']['bindingModel']();
            $rule1 = !empty($this->_config['bindingOptions']['rule']) ? $this->_config['bindingOptions']['rule'] : null;
            $rule2 = !empty($this->_config['bindingOptions']['rule2']) ? $this->_config['bindingOptions']['rule2'] : null;
            $modelReference = $bindingModel->getReference(get_class($model), $rule1);
            $filterModelReference = $bindingModel->getReference($this->_config['model'], $rule2);

            $joinConditions = array();
            foreach ($modelReference['refColumns'] as $i => $refColumn) {
                $column = $modelReference['columns'][$i];
                $joinCondition = '';
                $joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($refColumn);
                $joinCondition .= ' = ';
                $joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($column);
                $joinConditions[] = $joinCondition;
            }
            $joinConditions = implode(' AND ', $joinConditions);

            $countSelect = $model->select()
                ->from($model->getName(), array('c' => 'COUNT(*)'))
                ->join($bindingModel->getName(), $joinConditions, array());
            if ($where = $browsebox->getOption('conditions')) {
                $countSelect->where($where);
            }

            foreach ($filterModelReference['columns'] as $i => $foreignKey) {
                $countSelect->where($bindingModel->getAdapter()->quoteIdentifier($foreignKey).' = ?', $this->_params[$i]);
            }
            $result = $model->fetchRow($countSelect);
            return $result->c;
        } else {
            throw new Garp_Browsebox_Filter_Exception_NotApplicable();
        }
    }
public function fetchMaxChunks(Zend_Db_Select $select, Garp_Browsebox $browsebox) {
        if (!empty($this->_params)) {
            $model = $browsebox->getModel();
            $filterModel = new $this->_config['model']();
            $bindingModel = new $this->_config['bindingOptions']['bindingModel']();
            $rule1 = !empty($this->_config['bindingOptions']['rule']) ? $this->_config['bindingOptions']['rule'] : null;
            $rule2 = !empty($this->_config['bindingOptions']['rule2']) ? $this->_config['bindingOptions']['rule2'] : null;
            $modelReference = $bindingModel->getReference(get_class($model), $rule1);
            $filterModelReference = $bindingModel->getReference($this->_config['model'], $rule2);

            $joinConditions = array();
            foreach ($modelReference['refColumns'] as $i => $refColumn) {
                $column = $modelReference['columns'][$i];
                $joinCondition = '';
                $joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($refColumn);
                $joinCondition .= ' = ';
                $joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($column);
                $joinConditions[] = $joinCondition;
            }
            $joinConditions = implode(' AND ', $joinConditions);

            $countSelect = $model->select()
                ->from($model->getName(), array('c' => 'COUNT(*)'))
                ->join($bindingModel->getName(), $joinConditions, array());
            if ($where = $browsebox->getOption('conditions')) {
                $countSelect->where($where);
            }

            foreach ($filterModelReference['columns'] as $i => $foreignKey) {
                $countSelect->where($bindingModel->getAdapter()->quoteIdentifier($foreignKey).' = ?', $this->_params[$i]);
            }
            $result = $model->fetchRow($countSelect);
            return $result->c;
        } else {
            throw new Garp_Browsebox_Filter_Exception_NotApplicable();
        }
    }
public function fetchMaxChunks ( Zend_Db_Select $ select , Garp_Browsebox $ browsebox ) { if ( ! empty ( $ this -> _params ) ) { $ model = $ browsebox -> getModel ( ) ; $ filterModel = new $ this -> _config [ 'model' ] ( ) ; $ bindingModel = new $ this -> _config [ 'bindingOptions' ] [ 'bindingModel' ] ( ) ; $ rule1 = ! empty ( $ this -> _config [ 'bindingOptions' ] [ 'rule' ] ) ? $ this -> _config [ 'bindingOptions' ] [ 'rule' ] : null ; $ rule2 = ! empty ( $ this -> _config [ 'bindingOptions' ] [ 'rule2' ] ) ? $ this -> _config [ 'bindingOptions' ] [ 'rule2' ] : null ; $ modelReference = $ bindingModel -> getReference ( get_class ( $ model ) , $ rule1 ) ; $ filterModelReference = $ bindingModel -> getReference ( $ this -> _config [ 'model' ] , $ rule2 ) ; $ joinConditions = array ( ) ; foreach ( $ modelReference [ 'refColumns' ] as $ i => $ refColumn ) { $ column = $ modelReference [ 'columns' ] [ $ i ] ; $ joinCondition = '' ; $ joinCondition .= $ bindingModel -> getAdapter ( ) -> quoteIdentifier ( $ refColumn ) ; $ joinCondition .= ' = ' ; $ joinCondition .= $ bindingModel -> getAdapter ( ) -> quoteIdentifier ( $ column ) ; $ joinConditions [ ] = $ joinCondition ; } $ joinConditions = implode ( ' AND ' , $ joinConditions ) ; $ countSelect = $ model -> select ( ) -> from ( $ model -> getName ( ) , array ( 'c' => 'COUNT(*)' ) ) -> join ( $ bindingModel -> getName ( ) , $ joinConditions , array ( ) ) ; if ( $ where = $ browsebox -> getOption ( 'conditions' ) ) { $ countSelect -> where ( $ where ) ; } foreach ( $ filterModelReference [ 'columns' ] as $ i => $ foreignKey ) { $ countSelect -> where ( $ bindingModel -> getAdapter ( ) -> quoteIdentifier ( $ foreignKey ) . ' = ?' , $ this -> _params [ $ i ] ) ; } $ result = $ model -> fetchRow ( $ countSelect ) ; return $ result -> c ; } else { throw new Garp_Browsebox_Filter_Exception_NotApplicable ( ) ; } }
Fetch max amount of chunks.
@param Zend_Db_Select $select The specific select for this instance.
@param Garp_Browsebox $browsebox The browsebox, made available to fetch metadata from.
@return Void
Fetch max amount of chunks .