PDO prepared statement error

I am failing to understand what the error means in this case:

Basically i just wanted to try and use different fetch modes - ModelAbstractObject.php

line 22: public function find($id)
line 23: {
line 24:        $sql = "SELECT * FROM $this->table WHERE id=:id";
line 25:        $sth = $this->dbh->prepare($sql));
line 26:       $sth->bindParam(':id', $id, PDO::PARAM_INT);
line 27:        $sth->setFetchMode(PDO::FETCH_OBJ);
line 28:        $sth->execute();
line 29:        return $sth->fetchAll();
line 30: }


Catchable fatal error: Object of class Closure could not be converted to string in core/ModelAbstractObject.php on line 28

I sorted the problem.

What happened is that the parameter $id was being returned by a closure from another class and clearly PDO must have problems with closure - not sure either - but as soon as i returned the $id normally, it worked just fine. So there is the tip: “never return parameter from closure to be used with PDO” … made that one by myself :wink: