classes/database/orm.php
/**
	 * Tests if this object has a relationship with a another model.
	 *
	 * @param string $alias of the has_many ("through") relationship
	 * @param object $model the related ORM model
	 * @return boolean
	 */
Tests if this object has a relationship with a another model.
@param string $alias of the has_many ("through") relationship
@param object $model the related ORM model
@return boolean
Tests if this object has a relationship with a another model . @param string $alias of the has_many ( " through " ) relationship @param object $model the related ORM model @return boolean
public function has($alias, $model)
	{
		if(empty(self::$_aliases[$this->name()]['has_many'][$alias]))
		{
			throw new Exception($alias. ' alias is not found.');
		}
		$details = self::$_aliases[$this->name()]['has_many'][$alias];
		$sql = 'SELECT COUNT(*) FROM "'. $alias['through']. '" WHERE "'
		. $details['model'].$this->_foreign_key_suffix. '" = ? AND "'
		. $details['foreign_key']. '" = ?';
		return $this->_db->count($sql, array($model->pk(), $this->pk()));
	}
public function has ( $ alias , $ model ) { if ( empty ( self :: $ _aliases [ $ this -> name ( ) ] [ 'has_many' ] [ $ alias ] ) ) { throw new Exception ( $ alias . ' alias is not found.' ) ; } $ details = self :: $ _aliases [ $ this -> name ( ) ] [ 'has_many' ] [ $ alias ] ; $ sql = 'SELECT COUNT(*) FROM "' . $ alias [ 'through' ] . '" WHERE "' . $ details [ 'model' ] . $ this -> _foreign_key_suffix . '" = ? AND "' . $ details [ 'foreign_key' ] . '" = ?' ; return $ this -> _db -> count ( $ sql , array ( $ model -> pk ( ) , $ this -> pk ( ) ) ) ; }
Tests if this object has a relationship with a another model.
Tests if this object has a relationship with a another model .