Advertisement
gareth126

scott - code

Nov 22nd, 2011
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. class Application_Model_Albums extends Zend_Db_Table_Abstract
  4. {
  5.     protected $bootstrap;
  6.     protected $db;
  7.     //protected $_name = 'albulms';
  8.     //protected $_primary = 'id';
  9.    
  10.     //public $db;
  11.  
  12.    
  13.     function __construct(){
  14.        
  15.           /*$this->db = Zend_Db::factory('Pdo_Mysql', array(
  16.                                                 'host'
  17.                                                 => 'localhost',
  18.                                                 'username' => 'root',
  19.                                                 'password' => 'monkey12',
  20.                                                 'dbname'
  21.                                                 => 'zend_test'));
  22.         $this->db = $resource->getDbAdapter();*/
  23.         $this->bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
  24.         $this->db = $this->bootstrap->getResource('db');
  25.     }
  26.  
  27.    
  28.     public function getAlbums()
  29.     {
  30.         //get a new instance of the albulms model (each albulm is an object)
  31.         $albums = new Application_Model_Albums();
  32.         //using the albulm model can call special (fetch all and select where etc)
  33.         $albumList = $albums->fetchAll ( $albums->select()
  34.                                                 ->where ( 'id > ?', 1 ) );
  35.         //then can return the list of albums
  36.         return $albumList;
  37.        
  38.     }
  39.  
  40.    
  41. }
  42.  
  43. /*
  44. class Application_Model_Albums extends Zend_Db_Table_Abstract
  45. {
  46.         protected $_name = 'albums';
  47.         protected $_primary = 'id';
  48.        
  49. }
  50.  
  51. class Application_Model_Album
  52. {      
  53.         public function getAlbums()
  54.         {
  55.                 $albums = new Application_Model_Albums();
  56.                 $albumList = $albums->fetchAll(
  57.                         $albums->select()
  58.                                      ->where('id > ?', 1)
  59.                 );
  60.                 return $albumList;
  61.         }
  62.  
  63. class AlbumsController extends Zend_Controller_Action
  64. {
  65.         public function testAction()
  66.         {
  67.                 $albums = new Application_Model_Album();
  68.                 $this->view->results = $albums->getAlbums();
  69.         }
  70. }*/
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement