2013-06-03 24 views
1
public function executeProductAllAccept() 
    { 
     $this->observation = ObservationPeer::retrieveByPK($this->getRequestParameter('id')); 

     $this->forwardUnless((
      $this->observation 
     ), 'observation', 'error'); 

     $this->redirectUnless((
      $this->product 
     ), 'observation/error?flag=insufficientrights');  

     $currentTime = date('Y-m-d H:i:s'); 
     //echo $currentTime.'<br />'; 

     $this->observation->setIsSentBackToPM(0); 
     //echo 'after setIsSentBackToPM'.'<br />'; 
     $this->observation->setIsPartAccepted(0); 
     //echo 'after setIsPartAccepted'.'<br />'; 
     $this->observation->setIsHold(1); 
     //echo 'after setIsHold'.'<br />'; 
     $this->observation->setCostAllAcceptanceTime($currentTime); 
     //echo 'after setCostAllAcceptanceTime'.'<br />'; 
     $this->observation->save(); 
     //echo 'after save'.'<br />'; 
     //exit; 
     return $this->redirect('observation/myObservations'); 
    } 

此代碼返回空白頁。嘗試在開發環境 - >再次空白頁。Symfony 1.0.22對象保存失敗 - 爲什麼?如何調試呢?

因此,我添加了一些回聲來測試它的失敗。輸出是:

2013-06-03 10:40:20 
after setIsSentBackToPM 
after setIsPartAccepted 
after setIsHold 
after setCostAllAcceptanceTime 

所以這顯然在執行save()時失敗了。

看着symfony的日誌:

  • 沒有錯誤
  • 只有[資訊]關於SELECT查詢
  • 沒有[信息]關於設置查詢(這樣的東西在保存()失敗之前的symfony試圖執行查詢)

看着apache錯誤日誌 - >沒有錯誤。

所以我試着重建save方法 - > symfony propel-build-model。但問題依然存在。我將BaseObservation的保存方法與其他模型的保存方法進行了比較 - >我沒有看到任何異常。

我不知道如何跟蹤這個。有任何想法嗎?

編輯:更新的測試:

public function executeProductAllAccept() 
    { 
     $this->observation = ObservationPeer::retrieveByPK($this->getRequestParameter('id')); 

     echo 'before test plain save'.'<br />'; 
     $this->observation->save(); 
     echo 'after test plain save'.'<br />'; 

     $this->forwardUnless((
      $this->observation 
     ), 'observation', 'error'); 

     $this->redirectUnless((
      $this->product 
     ), 'observation/error?flag=insufficientrights');  

     $currentTime = date('Y-m-d H:i:s'); 
     echo $currentTime.'<br />'; 

     $this->observation->setIsSentBackToPM(0); 
     echo 'after setIsSentBackToPM'.'<br />'; 
     $this->observation->setIsPartAccepted(0); 
     echo 'after setIsPartAccepted'.'<br />'; 
     $this->observation->setIsHold(1); 
     echo 'after setIsHold'.'<br />'; 
     $this->observation->setCostAllAcceptanceTime($currentTime); 
     echo 'after setCostAllAcceptanceTime'.'<br />'; 
     $this->observation->save(); 
     echo 'after save'.'<br />'; 
     exit; 
     return $this->redirect('observation/myObservations'); 
    } 

返回:

before test plain save 
after test plain save 
2013-06-03 10:40:20 
after setIsSentBackToPM 
after setIsPartAccepted 
after setIsHold 
after setCostAllAcceptanceTime 
+1

您是否嘗試僅保存對象而不進行編輯?就像'retrieveByPK'之後? – j0k

+0

這很奇怪。我按照你的建議添加了一些代碼來測試,看起來像save()沒有編輯工作。請參閱編輯的文章現在我不知道我們可能會犯什麼錯誤。 – loostro

+1

我們可以看到您的schema.xml/yml嗎?你可以嘗試保存而不定義'setCostAllAcceptanceTime'? – j0k

回答

0

好,加入

error_reporting(E_ALL); 
ini_set('display_errors',TRUE); 

幫助解決問題。

在我的情況下,錯誤是:

Fatal error: Call to undefined method Observation::setCostAllAcceptanceTime() in /xxxxxxxxxxxxxx/modules/observation/actions/actions.class.php on line 792 

好像在架構更新的3條線之間的某個地方丟失了。當我生成新的模型,然後方法setCostAllAcceptanceTime(和2其他)沒有生成,並導致了錯誤。

相關問題