public function hasOne($model, $our_field = null, $display_field = null, $as_field = null)
    {

        // register reference, but don't create any fields there
        // parent::hasOne($model,null);
        // model, our_field
        $this->_references[null] = $model;

        if (!$our_field) {
            if (!is_object($model)) {
                $tmp = $this->app->normalizeClassName($model, 'Model');
                $tmp = new $tmp(); // avoid recursion
            } else {
                $tmp = $model;
            }
            $our_field = ($tmp->table).'_id';
        }

        /** @type Field_Reference $r */
        $r = $this->add('Field_Reference', array('name' => $our_field, 'dereferenced_field' => $as_field));
        $r->setModel($model, $display_field);
        $r->system(true)->editable(true);

        return $r;
    }
public function hasOne($model, $our_field = null, $display_field = null, $as_field = null)
    {

        // register reference, but don't create any fields there
        // parent::hasOne($model,null);
        // model, our_field
        $this->_references[null] = $model;

        if (!$our_field) {
            if (!is_object($model)) {
                $tmp = $this->app->normalizeClassName($model, 'Model');
                $tmp = new $tmp(); // avoid recursion
            } else {
                $tmp = $model;
            }
            $our_field = ($tmp->table).'_id';
        }

        /** @type Field_Reference $r */
        $r = $this->add('Field_Reference', array('name' => $our_field, 'dereferenced_field' => $as_field));
        $r->setModel($model, $display_field);
        $r->system(true)->editable(true);

        return $r;
    }
public function hasOne ( $ model , $ our_field = null , $ display_field = null , $ as_field = null ) { // register reference, but don't create any fields there // parent::hasOne($model,null); // model, our_field $ this -> _references [ null ] = $ model ; if ( ! $ our_field ) { if ( ! is_object ( $ model ) ) { $ tmp = $ this -> app -> normalizeClassName ( $ model , 'Model' ) ; $ tmp = new $ tmp ( ) ; // avoid recursion } else { $ tmp = $ model ; } $ our_field = ( $ tmp -> table ) . '_id' ; } /** @type Field_Reference $r */ $ r = $ this -> add ( 'Field_Reference' , array ( 'name' => $ our_field , 'dereferenced_field' => $ as_field ) ) ; $ r -> setModel ( $ model , $ display_field ) ; $ r -> system ( true ) -> editable ( true ) ; return $ r ; }
Defines one to many association
Defines one to many association