PDO PHP Fetch Class?

This basically means that when using PDO To return a result to a custom object your required to set out the variables that correspond to the MySQL result keys such as: class User { //Predefine Here public $id; public $username; public $password; public $email; public $hash; public function profileLink() { return sprintf('%s',$this->id,$this->username); } } $result = $sth->fetchAll(PDO::FETCH_CLASS, "User"); foreach($result as $user) { echo $user->profileLink(); } This way PDO can set the variables to the object outside of its internal scope if you user class was like so: class User { } then PDO Would not be able to set the values from outside the scope, as there are no public variables defined.

This basically means that when using PDO To return a result to a custom object your required to set out the variables that correspond to the MySQL result keys. Such as: class User { //Predefine Here public $id; public $username; public $password; public $email; public $hash; public function profileLink() { return sprintf('%s',$this->id,$this->username); } } $result = $sth->fetchAll(PDO::FETCH_CLASS, "User"); foreach($result as $user) { echo $user->profileLink(); } This way PDO can set the variables to the object outside of its internal scope. If you user class was like so: class User { } then PDO Would not be able to set the values from outside the scope, as there are no public variables defined.

The PHP Manual clearly states that to open a PDO connection, create a new Instance of the PDO Class. To close a PDO connection, destroy the Instance, possibly by setting it to a Null Reference. The PDO Instance in this case is your handle.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions