php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21186 Can not connect to Informix with DB::connect
Submitted: 2002-12-26 01:16 UTC Modified: 2003-01-03 06:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ckongsak at hotmail dot com Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.2.3 OS: linux (redhat 7.0)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ckongsak at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-12-26 01:16 UTC] ckongsak at hotmail dot 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 "||".


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-01 16:32 UTC] 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.
 [2003-01-01 21:54 UTC] ckongsak at hotmail dot 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-03 06:04 UTC] mj@php.net
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 02 15:01:26 2025 UTC