library/Garp/Model/Db.php
public function bindModel($alias, $options = array()) {
        if ($alias instanceof Garp_Model_Db) {
            $alias = get_class($alias);
        }

        if (!is_array($options) && !$options instanceof Garp_Util_Configuration) {
            throw new Exception('$options must be an array or Garp_Util_Configuration');
        }

        if (empty($options['modelClass'])
            && empty($options['rule'])
            && substr($alias, 0, 6) !== 'Model_'
        ) {
            // Assume $alias is actually a rule and fetch the required info from
            // the reference.
            $referenceMap = $this->_getReferenceMapNormalized();
            if (empty($referenceMap[$alias])) {
                throw new Exception(
                    'Not enough options given. Alias ' . $alias . ' is not usable as a rule.'
                );
            }
            $reference = $referenceMap[$alias];
            $options['modelClass'] = $reference['refTableClass'];
            $options['rule'] = $alias;
        }

        if (is_array($options)) {
            $options = new Garp_Util_Configuration($options);
        }
        $this->notifyObservers('beforeBindModel', array($this, $alias, &$options));
        Garp_Model_Db_BindingManager::storeBinding(get_class($this), $alias, $options);
        return $this;
    }
public function bindModel($alias, $options = array()) {
        if ($alias instanceof Garp_Model_Db) {
            $alias = get_class($alias);
        }

        if (!is_array($options) && !$options instanceof Garp_Util_Configuration) {
            throw new Exception('$options must be an array or Garp_Util_Configuration');
        }

        if (empty($options['modelClass'])
            && empty($options['rule'])
            && substr($alias, 0, 6) !== 'Model_'
        ) {
            // Assume $alias is actually a rule and fetch the required info from
            // the reference.
            $referenceMap = $this->_getReferenceMapNormalized();
            if (empty($referenceMap[$alias])) {
                throw new Exception(
                    'Not enough options given. Alias ' . $alias . ' is not usable as a rule.'
                );
            }
            $reference = $referenceMap[$alias];
            $options['modelClass'] = $reference['refTableClass'];
            $options['rule'] = $alias;
        }

        if (is_array($options)) {
            $options = new Garp_Util_Configuration($options);
        }
        $this->notifyObservers('beforeBindModel', array($this, $alias, &$options));
        Garp_Model_Db_BindingManager::storeBinding(get_class($this), $alias, $options);
        return $this;
    }
public function bindModel ( $ alias , $ options = array ( ) ) { if ( $ alias instanceof Garp_Model_Db ) { $ alias = get_class ( $ alias ) ; } if ( ! is_array ( $ options ) && ! $ options instanceof Garp_Util_Configuration ) { throw new Exception ( '$options must be an array or Garp_Util_Configuration' ) ; } if ( empty ( $ options [ 'modelClass' ] ) && empty ( $ options [ 'rule' ] ) && substr ( $ alias , 0 , 6 ) !== 'Model_' ) { // Assume $alias is actually a rule and fetch the required info from // the reference. $ referenceMap = $ this -> _getReferenceMapNormalized ( ) ; if ( empty ( $ referenceMap [ $ alias ] ) ) { throw new Exception ( 'Not enough options given. Alias ' . $ alias . ' is not usable as a rule.' ) ; } $ reference = $ referenceMap [ $ alias ] ; $ options [ 'modelClass' ] = $ reference [ 'refTableClass' ] ; $ options [ 'rule' ] = $ alias ; } if ( is_array ( $ options ) ) { $ options = new Garp_Util_Configuration ( $ options ) ; } $ this -> notifyObservers ( 'beforeBindModel' , array ( $ this , $ alias , & $ options ) ) ; Garp_Model_Db_BindingManager :: storeBinding ( get_class ( $ this ) , $ alias , $ options ) ; return $ this ; }
Bind model. This activates a relation between models. With the next
fetch operation related records from these models will be fetched
alongside the originally requested records.

@param string|Garp_Model_Db $alias An alias for the relationship. This name is used in
fetched rows to store the related records.
If $options['modelClass'] is not set, the alias is
also assumed to be the classname.
@param Garp_Util_Configuration|array $options Various relation options.
Note; for many-to-many relations the name of
the binding model must be given in
$options['bindingModel'].
@return Garp_Model $this
Bind model . This activates a relation between models . With the next fetch operation related records from these models will be fetched alongside the originally requested records .