Every now and then, I get into a situation when I have a query similar in kind to:
SELECT `key`, `value` FROM `settings`;
In this case, I w
$query = $db->query("SELECT `name` AS name, `value` AS value FROM `settings`;");
$result = $query->fetchAll(PDO::FETCH_ASSOC);
For your problem there is pretty ready solution, that is:
$q = $db->query("SELECT `name`, `value` FROM `settings`;");
$r = $q->fetchAll(PDO::FETCH_KEY_PAIR);
Works for me, on PostgreSQL 9.1, and PHP 5.3.8 running on Windows 7 x64.