src/xPDO/Om/xPDOObject.php
public function getOne($alias, $criteria= null, $cacheFlag= true) {
        $object= null;
        if ($fkdef= $this->getFKDefinition($alias)) {
            $k= $fkdef['local'];
            $fk= $fkdef['foreign'];
            if (isset ($this->_relatedObjects[$alias])) {
                if (is_object($this->_relatedObjects[$alias])) {
                    $object= & $this->_relatedObjects[$alias];
                    return $object;
                }
            }
            if ($criteria === null) {
                $criteria= array ($fk => $this->get($k));
                if (isset($fkdef['criteria']) && isset($fkdef['criteria']['foreign'])) {
                    $criteria= array($fkdef['criteria']['foreign'], $criteria);
                }
            }
            if ($object= $this->xpdo->getObject($fkdef['class'], $criteria, $cacheFlag)) {
                $this->_relatedObjects[$alias]= $object;
            }
        } else {
            $this->xpdo->log(xPDO::LOG_LEVEL_WARN, "Could not getOne: foreign key definition for alias {$alias} not found.");
        }
        return $object;
    }
public function getOne($alias, $criteria= null, $cacheFlag= true) {
        $object= null;
        if ($fkdef= $this->getFKDefinition($alias)) {
            $k= $fkdef['local'];
            $fk= $fkdef['foreign'];
            if (isset ($this->_relatedObjects[$alias])) {
                if (is_object($this->_relatedObjects[$alias])) {
                    $object= & $this->_relatedObjects[$alias];
                    return $object;
                }
            }
            if ($criteria === null) {
                $criteria= array ($fk => $this->get($k));
                if (isset($fkdef['criteria']) && isset($fkdef['criteria']['foreign'])) {
                    $criteria= array($fkdef['criteria']['foreign'], $criteria);
                }
            }
            if ($object= $this->xpdo->getObject($fkdef['class'], $criteria, $cacheFlag)) {
                $this->_relatedObjects[$alias]= $object;
            }
        } else {
            $this->xpdo->log(xPDO::LOG_LEVEL_WARN, "Could not getOne: foreign key definition for alias {$alias} not found.");
        }
        return $object;
    }
public function getOne ( $ alias , $ criteria = null , $ cacheFlag = true ) { $ object = null ; if ( $ fkdef = $ this -> getFKDefinition ( $ alias ) ) { $ k = $ fkdef [ 'local' ] ; $ fk = $ fkdef [ 'foreign' ] ; if ( isset ( $ this -> _relatedObjects [ $ alias ] ) ) { if ( is_object ( $ this -> _relatedObjects [ $ alias ] ) ) { $ object = & $ this -> _relatedObjects [ $ alias ] ; return $ object ; } } if ( $ criteria === null ) { $ criteria = array ( $ fk => $ this -> get ( $ k ) ) ; if ( isset ( $ fkdef [ 'criteria' ] ) && isset ( $ fkdef [ 'criteria' ] [ 'foreign' ] ) ) { $ criteria = array ( $ fkdef [ 'criteria' ] [ 'foreign' ] , $ criteria ) ; } } if ( $ object = $ this -> xpdo -> getObject ( $ fkdef [ 'class' ] , $ criteria , $ cacheFlag ) ) { $ this -> _relatedObjects [ $ alias ] = $ object ; } } else { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_WARN , "Could not getOne: foreign key definition for alias {$alias} not found." ) ; } return $ object ; }
Gets an object related to this instance by a foreign key relationship.

Use this for 1:? (one:zero-or-one) or 1:1 relationships, which you can
distinguish by setting the nullability of the field representing the
foreign key.

For all 1:* relationships for this instance, see {@link getMany()}.

@see xPDOObject::getMany()
@see xPDOObject::addOne()
@see xPDOObject::addMany()

@param string $alias Alias of the foreign class representing the related
object.
@param object $criteria xPDOCriteria object to get the related objects
@param boolean|integer $cacheFlag Indicates if the object should be
cached and optionally, by specifying an integer value, for how many
seconds.
@return xPDOObject|null The related object or null if no instance exists.
Gets an object related to this instance by a foreign key relationship .