Advertisement
dragonbe

Modified DB setup for ZF

Feb 24th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // application/Bootstrap.php
  2.     protected function _initDatabases()
  3.     {
  4.         $db = Zend_Db::factory('PDO_MySQL', array (
  5.             'hostname' => 'localhost',
  6.             'username' => 'zfessentials',
  7.             'password' => 'getsmart',
  8.             'dbname' => 'zfessentials',
  9.         ));
  10.     }
  11.  
  12. // OR in application/configs/application.ini
  13.  
  14. resources.db.adapter = "Pdo_Mysql"
  15. resources.db.params.hostname = localhost
  16. resources.db.params.username = zfessentials
  17. resources.db.params.password = getsmart
  18. resources.db.params.dbname = zfessentials
  19.  
  20. // application/controllers/DatabaseController.php
  21.  
  22.     public function indexAction()
  23.     {  
  24.         $bootstrap = $this->getInvokeArg('bootstrap');
  25.         $db = $bootstrap->getResource('db');
  26.         $this->view->users = $db->fetchAll(
  27.                                 $db->select()
  28.                                    ->from('users'));
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement