public function hasOne($model, $our_field = UNDEFINED, $field_class = UNDEFINED)
    {
        if ($field_class === UNDEFINED) {
            $field_class = $this->defaultHasOneFieldClass;
        }

        if ($our_field === UNDEFINED) {
            // guess our field
            $tmp = $this->app->normalizeClassName($model, 'Model');
            $tmp = new $tmp(); // avoid recursion
            $refFieldName = ($tmp->table ?: strtolower(get_class($this))).'_id';
        } else {
            $refFieldName = $our_field;
        }
        $displayFieldName = preg_replace('/_id$/', '', $our_field);

        $field = $this->addField($refFieldName);

        if (!@$this->controller->supportExpressions) {
            $expr = $this->addExpression($displayFieldName, $model, $field_class)
                ->setModel($model)
                ->setForeignFieldName($refFieldName);
            $this->_references[$refFieldName] = $model;

            return $expr;
        }

        return $field;
    }
public function hasOne($model, $our_field = UNDEFINED, $field_class = UNDEFINED)
    {
        if ($field_class === UNDEFINED) {
            $field_class = $this->defaultHasOneFieldClass;
        }

        if ($our_field === UNDEFINED) {
            // guess our field
            $tmp = $this->app->normalizeClassName($model, 'Model');
            $tmp = new $tmp(); // avoid recursion
            $refFieldName = ($tmp->table ?: strtolower(get_class($this))).'_id';
        } else {
            $refFieldName = $our_field;
        }
        $displayFieldName = preg_replace('/_id$/', '', $our_field);

        $field = $this->addField($refFieldName);

        if (!@$this->controller->supportExpressions) {
            $expr = $this->addExpression($displayFieldName, $model, $field_class)
                ->setModel($model)
                ->setForeignFieldName($refFieldName);
            $this->_references[$refFieldName] = $model;

            return $expr;
        }

        return $field;
    }
public function hasOne ( $ model , $ our_field = UNDEFINED , $ field_class = UNDEFINED ) { if ( $ field_class === UNDEFINED ) { $ field_class = $ this -> defaultHasOneFieldClass ; } if ( $ our_field === UNDEFINED ) { // guess our field $ tmp = $ this -> app -> normalizeClassName ( $ model , 'Model' ) ; $ tmp = new $ tmp ( ) ; // avoid recursion $ refFieldName = ( $ tmp -> table ? : strtolower ( get_class ( $ this ) ) ) . '_id' ; } else { $ refFieldName = $ our_field ; } $ displayFieldName = preg_replace ( '/_id$/' , '' , $ our_field ) ; $ field = $ this -> addField ( $ refFieldName ) ; if ( ! @ $ this -> controller -> supportExpressions ) { $ expr = $ this -> addExpression ( $ displayFieldName , $ model , $ field_class ) -> setModel ( $ model ) -> setForeignFieldName ( $ refFieldName ) ; $ this -> _references [ $ refFieldName ] = $ model ; return $ expr ; } return $ field ; }
{{{ Relational methods
{{{ Relational methods