Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // file: application/models/DbTable/User.php
- class Application_Model_DbTable_User extends Zend_Db_Table_Abstract
- {
- protected $_name = 'zfessentials';
- protected $_primary = 'id';
- }
- <?php
- //file: application/controllers/UserController.php
- class UserController extends Zend_Controller_Action
- {
- public function init()
- {
- /* Initialize action controller here */
- }
- public function indexAction()
- {
- $user = new Application_Model_DbTable_User();
- $this->view->users = $user->fetchAll();
- }
- public function oneAction()
- {
- $id = $this->getRequest()->getParam('id',0);
- $user = new Application_Model_DbTable_User();
- $this->view->user = $user->find($id);
- }
- }
- <?php //file: application/views/scripts/user/index.phtml ?>
- <?php if (!empty ($this->users)) : ?>
- <ul>
- <?php foreach ($this->user as $user): ?>
- <li><?php echo $this->escape($user->name); ?></li>
- <?php endforeach; ?>
- </ul>
- <?php else: ?>
- <p>No users found</p>
- <?php endif; ?>
- <?php //file: application/views/scripts/user/one.phtml ?>
- <?php if (!empty ($this->user)) : ?>
- <p>The name you have found: <?php echo $this->escape($user->name); ?></p>
- <?php else: ?>
- <p>No user found</p>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement