2011-12-17 73 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>"; 
}