Request seems to be processed but server returns error page
since I am using the ZendFramework again, I started to "extend" the QuickStart application.
I use the ZendX jQuery component as View Helper.
I have one Controller MonsterController
this has two actions besides indexAction:
addAction
attackAction
Both take params via _getParam($param, $default)
.
An example query for addAction would be /monster/add/dragon/health/100/attackDamage/23
.
attackAction just takes an Id.
The actual problem is, that if I call any of them I get an "Application Er开发者_Python百科ror". There is no stack trace or anything else than a plain page with "Application Error". Which should not happen.
The interesting thing is that, addAction actually perfoms an action adding the desired monster to the db, but attackAction just does nothing.
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));
}
}
Go to application\configs and you'll see there interesting file:
application.ini
Ctrl+F in it by "error" and you understand what to do next.
精彩评论