PDO -- perhaps understand error, do not know how to fix it

The message

Cannot use object of type lessons_select_recap_db as array in C:\xampp\htdocs\lessons\report\studentsession\form.php on line 21

I suspect the problem is that I am going against the same table from two different objects. (Though they are not active at the same time).

I build my form with data I pull from a mySql table by instantiating a object that inherits from the original connector object

Class lessons_select_recap_db
 extends lessons_template_db { 

A function call within this object provides one “row” from the (alesson) table that I use to populate the form and send the screen. (Which I assumed destroyed that class and its objects – including lessons_select_recap_db).

At that point, the user has the option to print a report that needs more data from that table, and in a different format, so in processing the form, I instantiate a reporting object

Class lessons_report_studentsession_Form
 extends lessons_report_Base

and try to instantiate that – Class lessons_select_recap_db –

and that’s when I get the above message.

So is suspect that I have a PDO object still out there that I need to either access (though the original “instantiator” class is long gone) or release.

Is PDOStatement::closeCursor the tool I need to release it? And, if so, I don’t set a sense of the syntax required from the documentation.

Whew!

– must have been non-printable character embedded in the command line.

Discovery by
(1) Creating a standalone to invoke the class.
(2) Invoked the class function using literal values (surprise: worked as expected).
(3) Replaced the literals one at a time with the variables (i.e. 3 tests) (surprise: worked as expected).
(4) Went back to the class in my system, commented out the original code line, and repeated (2) and (3) above. (same surprises).
(5) Compared original code to the replacement code that works – no difference – except that it worked.
Code that works:

$recapList = $recapObj->GetRecapList($this->selectVals['student'],$this->selectVals['sessionyear'], $this->selectVals['session']);

Original code that still gives the

Cannot use object … as array
error

$recapList = $recapObj->GetRecapList($this->selectVals['student'],$this->selectVals['sessionyear'], $this->selectVals['session']);

I see no difference.

Very aggravating.

Regards,

grNadpa

So you accidentally fixed something, but you still cannot what you did that fixed it?

That’s really annoying.

I don’t mind learning from my mistakes but when you have nothing to take away apart from maybe underlining the old adage that sometimes, the best solution is to retype the dubious lines of code from scratch, which then works - that can really get your goat. Mostly because it means you probably did make a mistake and could not even find it when staring at it.

Thanks for sharing!