Say I have an array which fetched a single row from my database via the PDO::FETCH_ASSOC method, which I would then assign to a variable like so:
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$result
now holds an array equal to the following:
Array (
[id] => 42
)
So, to assign the value 'id' to a variable by itself, I then have to go:
$id = $result['id'];
Is there a quicker way to do this, or even better, to make sure the query result from my database is a variable rather than an array directly, assuming the query is always guaranteed to return 1 result?