1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/codes/Object relational mapping - Relations - Foreign key associations - One-to-One.php
2007-02-23 23:02:59 +00:00

29 lines
888 B
PHP

<?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");
}
public function setTableDefition() {
$this->hasColumn("name","string",50);
$this->hasColumn("loginname","string",20);
$this->hasColumn("password","string",16);
// foreign key column for email ID
$this->hasColumn("email_id","integer");
}
}
class Email extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("address","string",150);
}
}
class Address extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn("street","string",50);
$this->hasColumn("user_id","integer");
}
}
?>