tags:

views:

91

answers:

1

Hi there,

I have the following "test-class" made on the fly: http://sumoin.pastebin.com/ff744ea4 No fine-tuning or something else, just a brief testing pdo class.

And I have the test.php: http://sumoin.pastebin.com/d70dcb4ec

The funny thing is:

The PDOStatement object is never returned directly and I it never gets assigned to $this->handler->stmt

but the executing $stmt->execute() works as fine as if everything is okey. But if I use $this->handler->stmt->someMethod I get the following error:

Fatal error: Call to a member function bindParam() on a non-object

(bindParam is just an example)

I already checked the query, and it has no mistakes in it, I tried to use "bindValue()", did not work. I tried to use integers instead of ':name' to assign values to parameters. I ran the pure query through the $this->handler->query() and it worked.

Where is the problem located? I do not want to assign my PDOStatement object while the runtime, I want it to be part of the class, when the "->prepare()" method is called.

Any ideas? Please don't hit me if there is a duplicate out there, but I did not found anything that helped me.

Information:

  • PHP5.2
  • PDO Extensions etc. installed
  • Apache2
  • MySQL5.1 (matching to the PDO version)
A: 

Workaround/Solution:

public function prepare($query)
{
 return $this->handler->prepare($query);

 //$stmt->setFetchMode(PDO::FETCH_ASSOC); // standard
 //return $this->stmt;
}

public function getStatement($query)
{
 $this->stmt = $this->prepare($query);
}
daemonfire300
This works, however, I do not know why, but after a brainstrom while sitting on the toilette/wc I got this idea ;)
daemonfire300