Databases Reference
In-Depth Information
You need to think of these URLs in terms of controller/action. The
IndexController fetches the existing movies' names and the respective votes
from the database and AddController handles adding new suggestions and
updating votes. You can have multiple presentation layers created in the views
directory, but for simplicity, we have a single presentation layer vote.php which
manipulates and presents the survey results.
Table 3-1 lists the files created for our movie example. You can download the
complete zip file from the redbook Web site. For download details, see
Appendix C, “Additional material” on page 319.
Table 3-1 Files for example application
Name
Type
Description
IndexController.php
Controller
Main controller
AddController.php
Controller
Contains add/update logic
vote.php
View
Presentation HTML
Let us look at the IndexController.php (Example 3-8) first. We have intentionally
left indexAction method untouched and created a voteAction() method. As a
result of this, the main URL to launch this application is:
http://localhost/index/vote
You can alternatively not have the voteAction() method and move the code
inside the indexAction method(). In that case, you launch the application with this
URL:
http://localhost/
Example 3-8 IndexController.php
<?php
Zend::loadClass('Zend_Controller_Action');
Zend::loadClass('Zend_View');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
}
public function noRouteAction()
{
$this → _redirect('/');
echo 'norouteaction';
}
public function voteAction()
 
 
Search WWH ::




Custom Search