Re: MDB2 and PostgreSQL
| From: | brian | Date: | Sun, 12 Nov 2006 20:31:29 +0000 |
| Subject: | Re: MDB2 and PostgreSQL | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25790@lists.php.net to get a copy of this message | ||
Alain Roger wrote:
Hi, I'm still working around my issue with MDB2 and MDB2_Driver_postgres global $dsn;I'm not sure about this, but the problem may lie in how you're instantiating the DB interface. Try it like this: require_once 'MDB2.php'; /* Or however you want to do this part. I'm assuming * you have some constants set for this. */ $db_user = isset($admin) ? DB_ADMIN_USER : DB_USER; $db_pass = isset($admin) ? DB_ADMIN_PASS : DB_PASS; /* host & port left out to force UNIX socket connection */ $dsn = array($options = array('debug' => 2, 'portability' =>MDB2_PORTABILITY_ALL,);$query = 'SELECT * from sp_u_001(\'all\')';$db2 = & new MDB2_Driver_pgsql(); $db2->connect($dsn); if (PEAR::isError($db2)) { die("Error connection :".$db2->getMessage()."<br><br>".$res->getUserinfo());}//$res =& $db2->query('SELECT * FROM articles'); $res = $db2->exec($query); if (PEAR::isError($res)) { die("Error connection :".$res->getMessage()."<br><br>".$res->getUserinfo());}it does not matter, query or exec functions produce the same error message :Error connection : MDB2 Error: not found connect: [Error message:extension pgsql is not compiled into PHP] where could be the problem ? pgsql is install via PHP.ini and works well if i do not use PEAR packages. thanks a lot for help,
'phptype' => 'pgsql',
'hostspec' => DB_HOST,
'database' => DB_DATABASE,
'username' => $db_user,
'password' => $db_pass
);
$options = array(
'debug' => 2,
'portability' => MDB2_PORTABILITY_ALL
);
/* **********************************
* This is the important difference
* **********************************
*/
$db2 =& MDB2::connect($dsn, $options);
if (PEAR::isError($db2))
{
die ('Failed to connect. ' . (DEBUG ? $db2->getUserInfo() : NULL));
}
/* optional
*/
$db2->loadModule('Extended');
$db2->setFetchMode (MDB2_FETCHMODE_ASSOC);
brian