Export to GitHub

db2php - issue #16

Undefined index when executing findById


Posted on Jul 3, 2012 by Happy Dog

What steps will reproduce the problem? 1. generate model for test table (2 fields - id, description) 2. execute $record =OrmtestModel::findById($db, 1);

I expect to get the record where id=1

but instead get the following error

Code: 8 Message: Undefined index: SELECT * FROM ormtest WHERE id=? File: OrmtestModel.class.php Line: 235

I am using version 1.105 in Netbeans 7.1.2

However, if I execute

Ormtest::findBySql($db, "select * from ormtest where id = 1")

The correct record is returned.

Comment #1

Posted on Jul 22, 2012 by Swift Kangaroo

I can confirm this bug on a PHP 5.3. enabled server. It seems like the null check within the prepareStatment class doesn't work. Faulty line:

if (null===self::$stmts[$statement][$dbInstanceId]) {

Comment #2

Posted on Aug 13, 2012 by Grumpy Horse

What database are you using? Maybe change the quote style when generating.

Comment #3

Posted on Aug 13, 2012 by Grumpy Horse

Oh, right :/ The reason for that was that array_key_exists() is unbelievably slow. What surprises me is that it should only emit a E_NOTICE instead of an error. Since php-5.3 breaks that code, I pushed a new version. Since this was built on my mobile phone and I don't have netbeans there, please tell me if the plugin works :)

Comment #4

Posted on Aug 13, 2012 by Happy Kangaroo

Work fine THX!

Status: New

Labels:
Type-Defect Priority-Medium