lib/db/cortex.php
protected function _hasRefsInMM($key, $filter, $options, $ttl=0) {
		$fieldConf = $this->fieldConf[$key]['has-many'];
		$rel = $this->getRelInstance($fieldConf[0],null,$key,true);
		$hasSet = $rel->find($filter,$options,$ttl);
		$result = false;
		if ($hasSet) {
			$hasIDs = $hasSet->getAll('_id',true);
			$mmTable = $this->mmTable($fieldConf,$key);
			$pivot = $this->getRelInstance(null,array('db'=>$this->db,'table'=>$mmTable));
			$filter = [$key.' IN ?',$hasIDs];
			if ($fieldConf['isSelf']) {
				$filter[0].= ' OR '.$key.'_ref IN ?';
				$filter[] = $hasIDs;
			}
			$pivotSet = $pivot->find($filter,null,$ttl);
			if ($pivotSet) {
				$result = $pivotSet->getAll($fieldConf['relField'],true);
				if ($fieldConf['isSelf'])
					$result = array_merge($result,
						$pivotSet->getAll($fieldConf['relField'].'_ref',true));
				$result = array_diff(array_unique($result),$hasIDs);
			}
		}
		return $result;
	}
protected function _hasRefsInMM($key, $filter, $options, $ttl=0) {
		$fieldConf = $this->fieldConf[$key]['has-many'];
		$rel = $this->getRelInstance($fieldConf[0],null,$key,true);
		$hasSet = $rel->find($filter,$options,$ttl);
		$result = false;
		if ($hasSet) {
			$hasIDs = $hasSet->getAll('_id',true);
			$mmTable = $this->mmTable($fieldConf,$key);
			$pivot = $this->getRelInstance(null,array('db'=>$this->db,'table'=>$mmTable));
			$filter = [$key.' IN ?',$hasIDs];
			if ($fieldConf['isSelf']) {
				$filter[0].= ' OR '.$key.'_ref IN ?';
				$filter[] = $hasIDs;
			}
			$pivotSet = $pivot->find($filter,null,$ttl);
			if ($pivotSet) {
				$result = $pivotSet->getAll($fieldConf['relField'],true);
				if ($fieldConf['isSelf'])
					$result = array_merge($result,
						$pivotSet->getAll($fieldConf['relField'].'_ref',true));
				$result = array_diff(array_unique($result),$hasIDs);
			}
		}
		return $result;
	}
protected function _hasRefsInMM ( $ key , $ filter , $ options , $ ttl = 0 ) { $ fieldConf = $ this -> fieldConf [ $ key ] [ 'has-many' ] ; $ rel = $ this -> getRelInstance ( $ fieldConf [ 0 ] , null , $ key , true ) ; $ hasSet = $ rel -> find ( $ filter , $ options , $ ttl ) ; $ result = false ; if ( $ hasSet ) { $ hasIDs = $ hasSet -> getAll ( '_id' , true ) ; $ mmTable = $ this -> mmTable ( $ fieldConf , $ key ) ; $ pivot = $ this -> getRelInstance ( null , array ( 'db' => $ this -> db , 'table' => $ mmTable ) ) ; $ filter = [ $ key . ' IN ?' , $ hasIDs ] ; if ( $ fieldConf [ 'isSelf' ] ) { $ filter [ 0 ] .= ' OR ' . $ key . '_ref IN ?' ; $ filter [ ] = $ hasIDs ; } $ pivotSet = $ pivot -> find ( $ filter , null , $ ttl ) ; if ( $ pivotSet ) { $ result = $ pivotSet -> getAll ( $ fieldConf [ 'relField' ] , true ) ; if ( $ fieldConf [ 'isSelf' ] ) $ result = array_merge ( $ result , $ pivotSet -> getAll ( $ fieldConf [ 'relField' ] . '_ref' , true ) ) ; $ result = array_diff ( array_unique ( $ result ) , $ hasIDs ) ; } } return $ result ; }
return IDs of own mappers that match the given relation filter on pivot tables
@param string $key
@param array $filter
@param array $options
@param int $ttl
@return array|false
return IDs of own mappers that match the given relation filter on pivot tables