#21186 [Opn->Csd]: Can not connect to Informix with DB::connect
| From: | mj@php.net | Date: | Fri, 03 Jan 2003 12:04:20 +0000 |
| Subject: | #21186 [Opn->Csd]: Can not connect to Informix with DB::connect | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-12059@lists.php.net to get a copy of this message | ||
ID: 21186
Updated by: mj@php.net
Reported By: ckongsak@hotmail.com
-Status: Open
+Status: Closed
Bug Type: PEAR related
Operating System: linux (redhat 7.0)
PHP Version: 4.2.3
New Comment:
You are right about the second issue. A fix for this has been commited
to CVS and will appear in the next release of PEAR::DB.
I suggest you file a new bug report for the first issue, so we can keep
track of it more easily.
Previous Comments:
------------------------------------------------------------------------
[2003-01-01 21:54:45] ckongsak@hotmail.com
First: About error code and message
===================================
I add the following code to the first line of method
'DB_ifx::connect'.
---------------
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
---------------
This means immediately return method DB_ifx::connect with error
DB_ERROR_EXTENSION_NOT_FOUND.
And display test.php again. Output of test.php is ...
---------------
test.php:40 => DB Error: no such database
---------------
So something goes wrong here.
Because error code and message don't match. The message should be
"extension not found".
To investigate more about this issue, I add the code "print_r($db)" to
show the contents of error object. Output is ...
---------------
db_error Object ( [error_message_prefix] => [mode] => 1 [level] => 1024
[code] => -25 [message] => DB Error: no such database [userinfo] =>
ifx://test:test@test/test [callback] => )
test.php:41 => DB Error: no such database
---------------
Developer can clearly see that code is -25 but message is "DB Error: no
such database".
Should I submit another Bug report about this issue ?
Second: About if statement in DB_ifx::connect
=============================================
Thiks about following expression.
---------------
$a || $b
---------------
Meaning of this expression is "TRUE if either $a or $b is TRUE".
Ok ?
So following if statement appeard in DB_ifx::connect.
---------------
if ((!DB::assertExtension('informix')) ||
(!DB::assertExtension('Informix'))) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
---------------
If system have two extension 'informix' and 'Informix', don't return
with error. But if system has only 'informix' or 'Informix' extension
(not both), return with error. Because one of DB::assertExtension()
returns false and logical not change it's value to true.
What is the developer intention for above if statement ?
To use informix, system should have both 'informix' and 'Informix'
extension ?
My system have only one extension 'Informix'. So above condition is
not met and return with error DB_ERROR_EXTENSION_NOT_FOUND.
Is this a intended behavior ?
------------------------------------------------------------------------
[2003-01-01 16:32:59] mj@php.net
If assertExtension() fails, PEAR::DB will return
DB_ERROR_EXTENSION_NOT_FOUND. But in your example, PEAR::DB returned
DB_ERROR_NOSUCHDB. This means that the connection to the server could
be established, but that the database was not found.
The reason for this is that the DSN, you're using, contains a database
name that does not exist.
------------------------------------------------------------------------
[2002-12-26 01:16:26] ckongsak@hotmail.com
When I try to use informix module in PEAR package. And I see that some
code is wrong.
this below is a source code for generate error.
-----------------
$db = DB::connect($dsn, true);
if (DB::isError($db)) {
die(__FILE__ . ':' . __LINE__ . ' => ' . $db->getMessage());
}
-----------------
this is a output about of the source code.
-----------------
test.php:40 => DBError: no such database
-----------------
After if i investigate in ifx.php, in connect function is wrong (may
be)
below is a current source code (ifx.php, v1.5)
----------------
if ((!DB::assertExtension('informix')) ||
(!DB::assertExtension('Informix'))) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
----------------
Condition in if statement should use "&&" instead of "||".
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21186&edit=1