classes/database/orm.php
/**
	 * Adds a new relationship to between this model and another.
	 *
	 * @param string $alias of the has_many "through" relationship
	 * @param object $model the related ORM model
	 * @return object
	 */
Adds a new relationship to between this model and another.
@param string $alias of the has_many "through" relationship
@param object $model the related ORM model
@return object
Adds a new relationship to between this model and another . @param string $alias of the has_many " through " relationship @param object $model the related ORM model @return object
public function add($alias, $model)
	{
		if(empty(self::$_aliases[$this->name()]['has_many'][$alias]))
		{
			throw new Exception($alias. ' alias is not found.');
		}
		$alias = self::$_aliases[$this->name()]['has_many'][$alias];
		$through = 'Model_'. $alias['through'];
		$through = new $through;
		$through->{$this->name().$this->_foreign_key_suffix} = $this->pk();
		$through->{$model->name().$this->_foreign_key_suffix} = $model->pk();
		$through->save();
		return $this;
	}
public function add ( $ alias , $ model ) { if ( empty ( self :: $ _aliases [ $ this -> name ( ) ] [ 'has_many' ] [ $ alias ] ) ) { throw new Exception ( $ alias . ' alias is not found.' ) ; } $ alias = self :: $ _aliases [ $ this -> name ( ) ] [ 'has_many' ] [ $ alias ] ; $ through = 'Model_' . $ alias [ 'through' ] ; $ through = new $ through ; $ through -> { $ this -> name ( ) . $ this -> _foreign_key_suffix } = $ this -> pk ( ) ; $ through -> { $ model -> name ( ) . $ this -> _foreign_key_suffix } = $ model -> pk ( ) ; $ through -> save ( ) ; return $ this ; }
Adds a new relationship to between this model and another.
Adds a new relationship to between this model and another .
/**
		 * The "through" table model might have it's own methods to run before the insert.
		 * So if specified, we should use *that model* to perform the action.
		 */ // Load the through-relationship model // Set these values // Create a new row