Home » Database » DB » Bug #5563
mysql connect() on php 4.1.x
Details
| Request #5563 | mysql connect() on php 4.1.x |
|---|---|
| Submitted | 2005-09-29 15:56 UTC |
| From | norbert_m at php dot net |
| Status | Wont fix |
| Package | DB |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-09-29 15:56 UTC] norbert_m at php dot net
Description:
------------
First of all, of course I know that PEAR requires PHP 4.2.0+.
On the other hand, I'm proud to announce that by adding a single condition to the source, the DB package works perfectly with the MySQL backend even on PHP 4.1.x!
Why I'm asking you to add this is that it doesn't hurt anyone but extends the portability of the package.
DB/mysql.php: Current Lines 217-229 (Revision 1.117):
if (!$persistent) {
if (isset($dsn['new_link'])
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true))
{
$params[] = true;
} else {
$params[] = false;
}
}
if (version_compare(phpversion(), '4.3.0', '>=')) {
$params[] = isset($dsn['client_flags'])
? $dsn['client_flags'] : null;
}
The lines above should be surrounded by the following condition:
if (version_compare(phpversion(), '4.2.0', '>=')) {
}
This way the $params[] array (which will be passed to mysql_connect() in the following lines) won't get more than 3 parameters in PHP 4.1.x and below.
Expected result:
----------------
connect() works fine even on php 4.1.x
Actual result:
--------------
connect() is failing because the 4th and 5th parameters of the mysql_connect() function didn't exist before php 4.1.2
However, this can be patched by adding a single, reasonable condition which has only advantages and no disadvantages, which means that DB/mysql will work in earlier versions of PHP as well.