1
0
mirror of synced 2025-01-09 10:37:09 +03:00
doctrine2/manual/codes/Object relational mapping - Relations - Foreign key associations - One-to-One.php

29 lines
888 B
PHP
Raw Normal View History

2006-07-24 01:08:06 +04:00
<?php
class User extends Doctrine_Record {
public function setUp() {
$this->hasOne('Address','Address.user_id');
$this->ownsOne('Email','User.email_id');
$this->ownsMany('Phonenumber','Phonenumber.user_id');
2006-07-24 01:08:06 +04:00
}
public function setTableDefition() {
$this->hasColumn('name','string',50);
$this->hasColumn('loginname','string',20);
$this->hasColumn('password','string',16);
2006-07-24 01:08:06 +04:00
// foreign key column for email ID
$this->hasColumn('email_id','integer');
2006-07-24 01:08:06 +04:00
}
}
class Email extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('address','string',150);
2006-07-24 01:08:06 +04:00
}
}
class Address extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('street','string',50);
$this->hasColumn('user_id','integer');
2006-07-24 01:08:06 +04:00
}
}
?>