zoukankan      html  css  js  c++  java
  • 在Zend Framework中配置数据库参数

    我是用zend studio 7.2.1建立的zend framework project

    也就是说我的框架是由zend stduio7.2.1 帮我建立了文件路径等信息的

    下面讲讲如何在建立好的zend framework project中配置mysql数据库信息

    1、

    在application/configs的文件下建立一个config.ini文件

    配置信息如下:

    [general]
    db.adapter=PDO_MYSQL
    db.config.host=localhost/IParess     
    db.config.username=username
    db.config.password=password
    db.config.dbname=databasename

    2、

    在pulibc 目录的index.php页面中

    /** Zend_Application */
    require_once 'Zend/Application.php';

    的下面插入

    //set the datase config
    require_once 'Zend/Config/Ini.php';
    require_once 'Zend/Registry.php';
    require_once 'Zend/Db.php';
    require_once 'Zend/Db/Table.php';
    $config=new Zend_Config_Ini('./../application/configs/config.ini',null, true);
    Zend_Registry::set('config',$config);
    $dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
    $dbAdapter->query('SET NAMES UTF8');
    Zend_Db_Table::setDefaultAdapter($dbAdapter);
    Zend_Registry::set('dbAdapter',$dbAdapter);

  • 相关阅读:
    oracle 删除表中重复数据留一条
    C# 特性
    oracle 常用简单命令语句
    2017年学习计划
    java web开发基础学习
    Java Axis2支持json
    java基础教程
    axis2 发布webservice
    孤荷凌寒自学python第103天认识区块链017
    孤荷凌寒自学python第102天认识区块链016
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/1862273.html
Copyright © 2011-2022 走看看