Configure DBAL via Symfony2 to return lowercase keys

I am using DBAL Doctrine 2 (but not ORM) in Symfony2 PR9. When I do the following

$conn = $this->get('doctrine.dbal.aademo_connection'); $user = $conn->fetchAssoc('SELECT * FROM users WHERE userid = 1'); 

Then all the keys in the returned array have the same slightly erroneous capitalization as the database columns. Unfortunately, I cannot accidentally rename the database columns. :-)

With PDO, I can make all keys have lowercase letters with the following:

 $conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); 

It seems that something should be similar in the Symfony2 file /app/config/config.yml , but I could not find such an opportunity registered on the Internet. Since Doctrine wraps PDO, is there a way to pass the ATTR_CASE parameter somehow?

+4
source share
1 answer

DBAL connection parameters may contain a parameter named driverOptions . This should be the same as an attribute array that can be provided to the PDO constructor (see Driver User Preferences ). Add it to doctrine.dbal.aademo_connection

+4
source

Source: https://habr.com/ru/post/1346131/


All Articles