Commit cab4750c authored by Bong Cosca's avatar Bong Cosca
Browse files

NEW: Cursor->xref() and Cursor->xrefone() methods; Return(s) cross-reference(s) to another mapper

parent 41a379ad
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -107,6 +107,30 @@ abstract class Cursor extends \Magic {
			$this->skip(0)?$this->query[$this->ptr=0]:FALSE;
	}

	/**
	*	Returns cross-references to another mapper
	*	@return array|FALSE
	*	@param $mapper object
	*	@param $filter string|array
	*	@param $options array
	**/
	function xref($mapper,$filter=NULL,array $options=NULL) {
		return $mapper->find($filter,$options);
	}

	/**
	*	Return first cross-reference to another mapper
	*	@return object|FALSE
	*	@param $mapper object
	*	@param $filter string|array
	*	@param $options array
	*	@param $ttl int
	**/
	function xrefone($mapper,$filter=NULL,array $options=NULL,$ttl=0) {
		return ($data=$this->xref($mapper,$filter,$options,$ttl))?
			$data[0]:FALSE;
	}

	/**
	*	Map to first record in cursor
	*	@return mixed