如何正确创建关系?

时间:2012-02-17 20:27:20

标签: php symfony1 propel

我使用Symfony 1和Propel。我的schema.yml:

user:
    _attributes:          { phpName: User }
    id:                      ~
    name:                 { type: varchar, size: 200 }

phones:
    _attributes:          { phpName: Phones }
    id:                    ~
    user_id:              { type: INTEGER, foreignTable: user, foreignReference: id }
    phone:                { type: varchar, size: 200 }
数据库中的

User:
id | user
1  | john

Phones:
id | user_id | phone
1  | 1       | 2234234
2  | 1       | 234234234

行动中:

$this->user_list = UserPeer::doSelect(new Criteria());
模板中的

foreach($user_list as $user){
  echo $user->getName();
  foreach ($user->getPhones as $phone){
    echo $phone->getPhone();
  }
}

这回报我: 调用未定义的方法BaseUser :: getPhones

我该如何纠正?

0 个答案:

没有答案