dousaoxiancy199896 2014-08-14 09:21
浏览 128
已采纳

调用未定义的方法MDB2_Error :: setFetchMode()

I am using PEAR's MDB2 to connect to my MySQL DB's.

I have never had a problem before but this particular host is causing me problems.

At first I thought it was the user credentials but I have tested on the same file with a standard MySQL code to connect successfully.

 //Error Code
 Fatal error: Call to undefined method MDB2_Error::setFetchMode() in /home/topazmar/public_html/db/db.php on line 15

 //Php Code
 $this->conn=MDB2::connect(array(
        'phptype'  => 'mysql',
        'username' => DATABASE_USR,
        'password' => DATABASE_PWD,
        'hostspec' => DATABASE_HOST,
        'database' => DATABASE_NAME,
    ));
    $this->conn->setFetchMode(MDB2_FETCHMODE_ASSOC); //Line 15

Edit

I outputting $this->conn with a dump

[0] => Array
            (
                [file] => /home/topazmar/public_html/db/MDB2.php
                [line] => 979
                [function] => PEAR_Error
                [class] => PEAR_Error
                [type] => ->
                [args] => Array
                    (
                        [0] => MDB2 Error: not found
                        [1] => -4
                        [2] => 1
                        [3] => 1024
                        [4] => unable to find package 'MDB2_Driver_mysql' file 'MDB2/Driver/mysql.php'
                    )

            )

I do have MDB2_Driver_mysql 1.4.1 installed along with PEAR and MDB2... Makes me confused, I don't imagine using modrewrites would change this at all.

  • 写回答

3条回答 默认 最新

  • duanhe4267 2014-08-14 09:26
    关注

    Your connection is failing and you get back error object (class MDB2_Error) instead of connection object (class extending MDB2_Driver_Common).

    Use PEAR::isError($this->conn) to check if the connection succceeded.

    [Edit - Hutber]

    This Means You Haven't connected to the db, pw problems, user not privaliaged etc

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器