Home  >  Article  >  Backend Development  >  Configure database parameters in Zend Framework

Configure database parameters in Zend Framework

WBOY
WBOYOriginal
2016-07-25 09:10:531056browse

Configure database parameters in Zend Framework

  1. I created the zend framework project using zend studio 7.2.1
  2. That is to say, my framework was created by zend stduio7.2.1 to help me create the file path and other information
  3. The following will talk about how to create a good zend framework Configure the mysql database information in the project
  4. 1.
  5. Create a config.ini file under the application/configs file
  6. The configuration information is as follows:
  7. [general]
  8. db.adapter=PDO_MYSQL
  9. db.config.host=localhost/IParess
  10. db .config.username=username
  11. db.config.password=password
  12. db.config.dbname=databasename
  13. 2,
  14. In the index.php page of the pulibc directory
  15. /**Zend_Application*/
  16. require_once 'Zend/ Application.php'; Insert
  17. //set the datase config
  18. require_once 'Zend/Config/Ini.php';
  19. require_once 'Zend/Registry.php';
  20. require_once 'Zend/Db.php';
  21. require_once 'Zend/Db/Table.php';
  22. $config=new Zend_Config_Ini('./../application/configs/config.ini',null, true);
  23. Zend_Registry::set('config',$config) ;
  24. $dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
  25. $dbAdapter ->query('SET NAMES UTF8');
  26. Zend_Db_Table::setDefaultAdapter($dbAdapter);
  27. Zend_Registry::set('dbAdapter',$dbAdapter);
Copy code

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn