を返しました。私はZendFrameworkを再び使用しているので、QuickStartアプリケーションを「拡張」し始めました。 ZendX jQueryコンポーネントをビューヘルパーとして使用します。リクエストが処理されたようですが、サーバがエラーページ
の両方が_getParam($param, $default)
経由のparamsを取る
addAction
attackAction: 私は、これはindexAction以外の二つの動作を持っている1つのコントローラー
MonsterController
を持っています。 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)); } }