2011-12-17 56 views
0

我在网站上建立了学说,我在关系上遇到了麻烦。我有一个拥有多个配置文件的帐户对象。每个配置文件有一个帐户。当我尝试创建一个新的配置文件并坚持然后刷新时,表单会挂起而不执行任何操作。如果我删除了flush,我得到打印的调试语句,但没有任何东西被持久化。与学说的关系麻烦PHP

模型属性。

在帐户

/** 
* The profiles belonging to this account. 
* 
* @OneToMany(targetEntity="Profile_Model_Profile", mappedBy="account") 
*/ 
protected $profiles; 

在档案

/** 
    * The account that owns this profile 
    * 
    * @ManyToOne(targetEntity="Account_Model_Account", 
       inversedBy="profiles", 
       cascade={"detach", "persist", "merge"}, 
       fetch="EAGER") 
    * @JoinColumn(name="account_id", referencedColumnName="id") 
    */ 
protected $account; 

创建(设置所有属性后)

$profile->setAccount($account); 
$account->addProfile($profile); 

$em->persist($profile); 
$em->persist($account); 
$em->flush(); 

我在做什么错在这里?

+0

从问题标题看来,您听起来应该已经购买了PHP教程PHP情人节礼物,并没有花费太多时间检查出现的所有其他热门框架。 – rdlowrey 2011-12-17 01:10:07

回答

0

刚刚重访了这一点。我在Safari Web Inspector中看到,在尝试保留帐户时发生500错误。它只是没有在屏幕上显示任何内容。根据这篇文章,Codeigniter and Doctrine 500 internal error,我使用\ Exception代替Exception,将所有内容都包含在try catch中,并能够获取有关它崩溃原因的详细信息。

try{ 
     ... 
}catch (\Exception $e) {    
     echo "<pre>Error: " . $e . "</pre>"; 
}