I don't know why I cannot set the default fetch mode of PDO to FETCH_UNIQUE
Here is how I create the PDO object and make my request :
$PDO = new PDO($mysql,$login,$password);
$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_UNIQUE);
$prep = $PDO->prepare($selectQuery);
$prep->execute($params);
Then...
This is not working (it does not take into account the previous setAttribute()) :
$result = $prep->fetchAll();
This is working, but I don't want to have to write "PDO::FETH_UNIQUE" for every requests :
$result = $prep->fetchAll(PDO::FETCH_UNIQUE);
What am I doing wrong ? My goal is to get the result array indexed by the primary key of the selected table, exactly like on this thread : Is there a way to fetch associative array grouped by the values of a specified column with PDO?