Reputation: 28096
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.
Upvotes: 0
Views: 9233
Reputation: 7423
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
Upvotes: 2
Reputation: 415
In case someone sees this thread and they did install MDB2 and the db drivers correctly: I had the same issue and it turned out I had set insufficient permissions for the db user. Durrr
Upvotes: 1
Reputation: 28096
So for me what fixed it was as simple as installing the MDB2 library from pear.
Assuming you already have PEAR installed:
pear install MDB2
pear install MDB2#mysql
From a terminal/cmd window, then I was good to go.
Upvotes: 0