|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 "||".
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
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 ?