With PDO you can pick up a standard object just by specifying the type of return of consultation PDO::FETCH_OBJ:
$db = new PDO('mysql:host=localhost;dbname=test','usuario','senha');
$sql = "select * from pessoas limit 5";
$stmt = $db->prepare($sql);
$stmt->execute();
$arr = $stmt->fetchAll(PDO::FETCH_OBJ);
The output is an array containing objects of the standard class the properties will have the same name as the fields that are in the database. Something more or less like this:
[0] => stdClass Object
(
[id_pessoa] => 1
[nomeCompleto] => joão da silva
[idade] => 20
)
To access:
echo $pessoa->NomeCompleto .' - ' . $pessoa->idade;
You are using PDO, mysqli, mysql_* ?
– rray
I updated the question.
– Leandro Curioso
That one
vo
has some method that processes something or has only properties?– rray
No it would be a simple VO. The classic POJO in java.
– Leandro Curioso
No get and set methods.
– Leandro Curioso