Friday, 9 August 2013

PHP PDO query: fetch a field from the first row

PHP PDO query: fetch a field from the first row

I am trying to retrieve a specific field from the first row of my query
results. The following works just fine...
$result = $db->query($query);
$firstrow = $result->fetch();
$desired_field = $firstrow["field"];
My question is, can i do this in one step without storing the first row of
results in a variable? Thanks in advance!

No comments:

Post a Comment