I still don't understand why FETCH_KEY_PAIR is not documented here (http://php.net/manual/fr/pdo.constants.php), because it could be very useful!
<?php
var_dump($pdo->query('select id, name from table')->fetchAll(PDO::FETCH_KEY_PAIR));
?>
This will display:
array(2) {
[2]=>
string(10) "name2"
[5]=>
string(10) "name5"
}