2011-05-22 68 views
0

由於我再次使用ZendFramework,我開始「擴展」QuickStart應用程序。 我使用ZendX jQuery組件作爲View Helper。 我有一個控制器MonsterController這有除的indexAction兩個動作:似乎要求處理請求,但服務器返回錯誤頁面

的addAction

attackAction

雙方通過_getParam($param, $default)採取PARAMS。 addAction的示例查詢將是/monster/add/dragon/health/100/attackDamage/23。 attackAction只需要一個Id。

實際的問題是,如果我打電話給他們中的任何一個,我會得到一個「應用程序錯誤」。 沒有堆棧跟蹤或其他任何與「應用程序錯誤」的普通頁面。 這不應該發生。

有趣的是,addAction實際上執行了一個操作,將所需的怪物添加到數據庫中,但是attackAction什麼都不做。

public function attackAction() 
{ 
    $id = $this->_getParam("id", null); 
    $mapper = new Application_Model_MonsterMapper(); 
    $monster = new Application_Model_Monster(array("Id" => $id, "health" => 1)); 
    $mapper->save($monster); 
} 

public function addAction() 
{ 
    $monster = new Application_Model_Monster(); 
    $monster->setName($this->_getParam("name", "")) 
      ->setHealth($this->_getParam("health", 0)) 
      ->setAttackDamage($this->_getParam("attackDamage", 0)); 
    $mapper = new Application_Model_MonsterMapper(); 
    $mapper->save($monster); 
} 

public function save(Application_Model_Monster $model) 
{ 
    $data = array(
      'name' => $model->getName(), 
      'health' => $model->getHealth(), 
      'attackDamage' => $model->getAttackDamage() 
        ); 
    if (null === ($id = $model->getId())) { 
     unset($data['id']); 
     $this->getDbTable()->insert($data); 
    } else { 
     $this->getDbTable()->update($data, array('id = ?' => $id)); 
    } 
} 

回答

1

轉到應用程序\ CONFIGS,你會看到有感興趣的文件:用「錯誤」

application.ini 

按Ctrl + F在它和你明白下一步該怎麼做。

相關問題