Configuring database parameters in the Zend Framework

Source: Internet
Author: User
Tags zend framework

Configuring database parameters in the Zend Framework

  1. I'm a Zend Framework project built with Zend Studio 7.2.1.
  2. That is to say, my framework was created by Zend stduio7.2.1 to help me set up the file path and other information
  3. Here's how to configure MySQL database information in the built-in Zend Framework 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 ';
  17. The following insert
  18. Set the Datase config
  19. Require_once ' zend/config/ini.php ';
  20. Require_once ' zend/registry.php ';
  21. Require_once ' zend/db.php ';
  22. Require_once ' zend/db/table.php ';
  23. $config =new Zend_config_ini ('./. /application/configs/config.ini ', NULL, true);
  24. Zend_registry::set (' config ', $config);
  25. $dbAdapter =zend_db::factory ($config->general->db->adapter, $config->general->db->config-> ToArray ());
  26. $dbAdapter->query (' SET NAMES UTF8 ');
  27. Zend_db_table::setdefaultadapter ($dbAdapter);
  28. Zend_registry::set (' Dbadapter ', $dbAdapter);
Copy Code

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.