Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Application_Model_Albums extends Zend_Db_Table_Abstract
- {
- protected $bootstrap;
- protected $db;
- //protected $_name = 'albulms';
- //protected $_primary = 'id';
- //public $db;
- function __construct(){
- /*$this->db = Zend_Db::factory('Pdo_Mysql', array(
- 'host'
- => 'localhost',
- 'username' => 'root',
- 'password' => 'monkey12',
- 'dbname'
- => 'zend_test'));
- $this->db = $resource->getDbAdapter();*/
- $this->bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
- $this->db = $this->bootstrap->getResource('db');
- }
- public function getAlbums()
- {
- //get a new instance of the albulms model (each albulm is an object)
- $albums = new Application_Model_Albums();
- //using the albulm model can call special (fetch all and select where etc)
- $albumList = $albums->fetchAll ( $albums->select()
- ->where ( 'id > ?', 1 ) );
- //then can return the list of albums
- return $albumList;
- }
- }
- /*
- class Application_Model_Albums extends Zend_Db_Table_Abstract
- {
- protected $_name = 'albums';
- protected $_primary = 'id';
- }
- class Application_Model_Album
- {
- public function getAlbums()
- {
- $albums = new Application_Model_Albums();
- $albumList = $albums->fetchAll(
- $albums->select()
- ->where('id > ?', 1)
- );
- return $albumList;
- }
- class AlbumsController extends Zend_Controller_Action
- {
- public function testAction()
- {
- $albums = new Application_Model_Album();
- $this->view->results = $albums->getAlbums();
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement