【发布时间】:2010-06-15 02:02:36
【问题描述】:
我有一个 Profile 模型,它与一个 Detail 模型具有 hasOne 关系。我有一个注册表单,可以将数据保存到两个模型的表中,但我希望将配置文件模型中的username 字段复制到详细信息模型中的username字段,以便每个都具有相同的@987654323 @。
function new_account()
{
if(!empty($this->data))
{
$this->Profile->modified = date("Y-m-d H:i:s");
if($this->Profile->save($this->data))
{
$this->data['Detail']['profile_id'] = $this->Profile->id;
$this->data['Detail']['username'] = $this->Profile->username;
$this->Profile->Detail->save($this->data);
$this->Session->setFlash('Your registration was successful.');
$this->redirect(array('action'=>'index'));
}
}
}
我的配置文件控制器中的这段代码给了我错误:
Undefined property: Profile::$username
有什么想法吗?
【问题讨论】:
标签: php mysql cakephp frameworks