PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #8562

E_NOTICE error on line 2495 of MDB2.php

Details

Submitted2006-08-25 19:58 UTC
Frompwaring at gmail dot com
StatusBogus
PackageMDB2
PHP VersionIrrelevant
OSFreeBSD
Roadmaps(Not assigned)

Comments

[2006-08-25 19:58 UTC] pwaring at gmail dot com

Description:
------------
When running a script that uses MDB2 I get the following error:

Notice: Only variables should be assigned by reference in /path/to/MDB2.php on line 2495

The part where the script appears to insert this notice is:

$affected_rows = $sth->execute($data);

Looking at line 2495 of MDB2.php on my installation, the code that appears to be producing the error is:

$result =& $this->_doQuery($query, false, $connection, $this->database_name);

Test script:
---------------
// assume $dsn and $options are set to the correct values for the local database

$db =& MDB2::factory($dsn, $options);

$sql = "SELECT * FROM table WHERE id = :id";

$data = array('id' => 1);

$sth = $db->prepare($sql);

$affected_rows = $sth->execute($data);

$db->disconnect();

Expected result:
----------------
The script should execute without any errors.

Actual result:
--------------
Notice: Only variables should be assigned by reference in /path/to/MDB2.php on line 2495

[2006-08-25 21:13 UTC] pwaring at gmail dot com

MySQL 1.2.1 driver. I didn't actually install the driver at first, but adding it made no difference. I'm sure it's querying the database correctly because when I replace the SELECT with an INSERT the row gets added to the database but the same error is displayed.

[2006-08-26 09:50 UTC] pwaring at gmail dot com

I'm running PHP 4.4.4 (cli) (built: Aug 20 2006 10:51:38). I've not set any $options (it's just an empty array) and the $dsn is defined as:

$default_dsn = array(
'phptype' => DB_TYPE,
'username' => DB_USER,
'password' => DB_PASSWORD,
'hostspec' => DB_HOST,
'database' => DB_NAME,
'new_link' => true
);

All those constants are defined in a separate file which is imported using require_once. I don't think it's a problem with my code per se because the SQL statements are being executed - if I use an INSERT I can see the row being added as it should be. So the database connection is definitely being established and the queries seem to be executing.

As for installation, I just downloaded the MDB2 and driver packages and extracted them, then included the MDB2.php file. I can't really see it being a problem with missing files or files being in the wrong place, because surely that would raise an error when they were imported?

The only reason I can think of off the top of my head for this not showing up for anyone else is that your php.ini settings are different - I have E_NOTICE enabled, which is different from the default.

[2006-08-26 10:07 UTC] pwaring at gmail dot com

Ah, it turned out that there was an older version of MDB2 on the machine, 2.0.0-beta2. I think I'd installed that and then decided not to use it as the package was so far behind the upstream. I thought I'd removed it but there must been some files left over - forcing a removal seems to have solved the problem and the error has gone away now.

Sorry about that, I'll close the bug and chase after the FreeBSD package maintainer to get the release to match upstream.