zoukankan      html  css  js  c++  java
  • Zend_Db_Table::getDefaultAdapter is not working

    在Bootstrap中使用

            $url = constant ( "APPLICATION_PATH" ) . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'application.ini';
    	$dbconfig = new Zend_Config_Ini ( $url, "mysql" );
            // $db = Zend_Db::factory ( $dbconfig->db );
    	$db = Zend_Db_Table::getDefaultAdapter ();
    	// var_dump ( $db );
    	$db->query ( "set names utf8" );
    	// Zend_Db_Table::setDefaultAdapter ( $db );	
    会出现$db不能实例化的情况,当中Application.ini文件的内容例如以下:

    [mysql]
    resources.db.adatper=PDO_MYSQL
    resources.db.isDefaultTableAdapter = true
    resources.db.params.host=localhost
    resources.db.params.username=root
    resources.db.params.password=admin
    resources.db.params.dbname=hsp

    在这样的情况下须要使用例如以下方法:

            $db = Zend_Db::factory ( 'PDO_MYSQL', array (
    	'host' => 'localhost',
    	'username' => 'root',
            'password' => 'admin',
    	'dbname' => 'hsp' 
    	) );
            $db->query ( "set names utf8" );
            Zend_Db_Table::setDefaultAdapter ( $db );

    这样的方法能够正确的实例化$db。











  • 相关阅读:
    html+css设计简单的博客首页
    js基础知识总结(一)
    css基础知识总结
    HTML基础知识
    链表常见题目--附具体分析和代码
    程序的内存分配
    python线程互斥锁递归锁死锁
    动态规划算法python实现
    ECMAScript 6 开篇准备
    弦生成器
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4079977.html
Copyright © 2011-2022 走看看