hasOne() public method

Defines one to many association
public hasOne ( $model, $our_field = null, $display_field = null, $as_field = null )
Example #1
0
 public function hasOne($model, $our_field = UNDEFINED, $field_class = UNDEFINED)
 {
     // @todo Should check field types. There is some kind of mix of SQL fields and base fields
     /** @type Field_SQL_HasOne $field */
     $field = $this->model->hasOne($model, $our_field, $field_class);
     $field->table($this->joinAlias);
     /** @type Field_SQL_HasOne $foreign_field */
     $foreign_field = $this->model->getElement($field->getForeignFieldName());
     $foreign_field->table($this->joinAlias);
     return $field;
 }
Example #2
0
 public function hasOne($model, $our_field = null, $display_field = null)
 {
     return $this->owner->hasOne($model, $our_field, $display_field)->from($this);
 }