1
I’m starting to use PDO in my PHP projects. When I worked with mysql, without PDO, when I took a query in the BD, I was able to get each data associated to a variable and could do what I wanted with it. Now using PDO, how can I do this data manipulation?
For an example: I would do that..
$contas_entrada = mysql_query("SELECT valor FROM entrada WHERE id_empresa='$id_empresa' ORDER BY data DESC");
while($entrada_row = mysql_fetch_array($contas_entrada)){
$valor = $entrada_row['valor'];
}
Then I could work on the $value variable to work on it. How can I get data, via PDO, to manipulate them?
All right, I’ll try @rray. My other question, I haven’t found a solution yet. Do you have an email for us? Abs.
– GustavoSevero
i got used to doing the query, like this: $pegaData=$Pdo->prepare("SELECT data FROM input WHERE id_input=:id"); $pegaData->bindValue(":id", 30); How can I get the date from here?
– GustavoSevero
$pegaData=$pdo->prepare("SELECT data FROM entrada WHERE id_entrada=:id");
$pegaData->bindValue(":id", 30);
$pegaData->execute();
$res = $pegaData->fetchAll(PDO::FETCH_ASSOC);
print_r($res);
@Gustavosevero– rray
Now appeared... "Array ( [0] => Array ( [date] => 2014-05-05 ) - Light Bill - 50.00"
– GustavoSevero
@Gustavosevero, it means it worked! : D. Use the
fetchAll()
when you know that the query will return several lines andfetch()
when return only one line.– rray
All right, I’ll check it out.
– GustavoSevero
Perfect, I got it. Thanks. Give me your email?
– GustavoSevero
@Gustavosevero, step just wait for me to get home
– rray
Of course! Hehehehehehe
– GustavoSevero
@Gustavosevero ta ai?
– rray