lib/db/cortex.php
protected function getRelInstance($model=null, $relConf=null, $key='', $pushFilter=false) {
		if (!$model && !$relConf)
			trigger_error(self::E_MISSING_REL_CONF,E_USER_ERROR);
		$relConf = $model ? $model::resolveConfiguration() : $relConf;
		$relName = ($model?:'Cortex').'\\'.$relConf['db']->uuid().
			'\\'.$relConf['table'].'\\'.$key;
		if (\Registry::exists($relName)) {
			$rel = \Registry::get($relName);
			$rel->reset();
		} else {
			$rel = $model ? new $model : new Cortex($relConf['db'], $relConf['table']);
			if (!$rel instanceof Cortex)
				trigger_error(self::E_WRONG_RELATION_CLASS,E_USER_ERROR);
			\Registry::set($relName, $rel);
		}
		// restrict fields of related mapper
		if(!empty($key) && isset($this->relWhitelist[$key])) {
			if (isset($this->relWhitelist[$key][0]))
				$rel->fields($this->relWhitelist[$key][0],false);
			if (isset($this->relWhitelist[$key][1]))
				$rel->fields($this->relWhitelist[$key][1],true);
		}
		if ($pushFilter && !empty($key)) {
			if (isset($this->relFilter[$key.'.'])) {
				foreach($this->relFilter[$key.'.'] as $fkey=>$conf)
					$rel->filter($fkey,$conf[0],$conf[1]);
			}
			if (isset($this->hasCond[$key.'.'])) {
				foreach($this->hasCond[$key.'.'] as $fkey=>$conf)
					$rel->has($fkey,$conf[0],$conf[1]);
			}
		}
		return $rel;
	}
protected function getRelInstance($model=null, $relConf=null, $key='', $pushFilter=false) {
		if (!$model && !$relConf)
			trigger_error(self::E_MISSING_REL_CONF,E_USER_ERROR);
		$relConf = $model ? $model::resolveConfiguration() : $relConf;
		$relName = ($model?:'Cortex').'\\'.$relConf['db']->uuid().
			'\\'.$relConf['table'].'\\'.$key;
		if (\Registry::exists($relName)) {
			$rel = \Registry::get($relName);
			$rel->reset();
		} else {
			$rel = $model ? new $model : new Cortex($relConf['db'], $relConf['table']);
			if (!$rel instanceof Cortex)
				trigger_error(self::E_WRONG_RELATION_CLASS,E_USER_ERROR);
			\Registry::set($relName, $rel);
		}
		// restrict fields of related mapper
		if(!empty($key) && isset($this->relWhitelist[$key])) {
			if (isset($this->relWhitelist[$key][0]))
				$rel->fields($this->relWhitelist[$key][0],false);
			if (isset($this->relWhitelist[$key][1]))
				$rel->fields($this->relWhitelist[$key][1],true);
		}
		if ($pushFilter && !empty($key)) {
			if (isset($this->relFilter[$key.'.'])) {
				foreach($this->relFilter[$key.'.'] as $fkey=>$conf)
					$rel->filter($fkey,$conf[0],$conf[1]);
			}
			if (isset($this->hasCond[$key.'.'])) {
				foreach($this->hasCond[$key.'.'] as $fkey=>$conf)
					$rel->has($fkey,$conf[0],$conf[1]);
			}
		}
		return $rel;
	}
protected function getRelInstance ( $ model = null , $ relConf = null , $ key = '' , $ pushFilter = false ) { if ( ! $ model && ! $ relConf ) trigger_error ( self :: E_MISSING_REL_CONF , E_USER_ERROR ) ; $ relConf = $ model ? $ model :: resolveConfiguration ( ) : $ relConf ; $ relName = ( $ model ? : 'Cortex' ) . '\\' . $ relConf [ 'db' ] -> uuid ( ) . '\\' . $ relConf [ 'table' ] . '\\' . $ key ; if ( \ Registry :: exists ( $ relName ) ) { $ rel = \ Registry :: get ( $ relName ) ; $ rel -> reset ( ) ; } else { $ rel = $ model ? new $ model : new Cortex ( $ relConf [ 'db' ] , $ relConf [ 'table' ] ) ; if ( ! $ rel instanceof Cortex ) trigger_error ( self :: E_WRONG_RELATION_CLASS , E_USER_ERROR ) ; \ Registry :: set ( $ relName , $ rel ) ; } // restrict fields of related mapper if ( ! empty ( $ key ) && isset ( $ this -> relWhitelist [ $ key ] ) ) { if ( isset ( $ this -> relWhitelist [ $ key ] [ 0 ] ) ) $ rel -> fields ( $ this -> relWhitelist [ $ key ] [ 0 ] , false ) ; if ( isset ( $ this -> relWhitelist [ $ key ] [ 1 ] ) ) $ rel -> fields ( $ this -> relWhitelist [ $ key ] [ 1 ] , true ) ; } if ( $ pushFilter && ! empty ( $ key ) ) { if ( isset ( $ this -> relFilter [ $ key . '.' ] ) ) { foreach ( $ this -> relFilter [ $ key . '.' ] as $ fkey => $ conf ) $ rel -> filter ( $ fkey , $ conf [ 0 ] , $ conf [ 1 ] ) ; } if ( isset ( $ this -> hasCond [ $ key . '.' ] ) ) { foreach ( $ this -> hasCond [ $ key . '.' ] as $ fkey => $ conf ) $ rel -> has ( $ fkey , $ conf [ 0 ] , $ conf [ 1 ] ) ; } } return $ rel ; }
creates and caches related mapper objects
@param string $model
@param array $relConf
@param string $key
@param bool $pushFilter
@return Cortex
creates and caches related mapper objects