[RFC] [Discussion] Enable selecting a group by column name in PDO::FETCH_GROUP

From: Date: Sun, 22 Nov 2026 07:30:59 +0000
Subject: [RFC] [Discussion] Enable selecting a group by column name in PDO::FETCH_GROUP
Groups: php.internals 
Request: Send a blank email to internals+get-133179@lists.php.net to get a copy of this message
Hi internals, I would like to discuss adding the ability to select the group key when selecting PDO::FETCH_GROUP attribute. Basically, the flag will let PDO group results by the very first selected column in the written query. This means that you must get the grouping key at the first of your query. By allowing fetchAll method to accept a second query when use the FETCH_GROUP attr, we can now pick a specific column to group the output results with. There are no BC issues, skipping providing the second argument will use the default behavior. Tho, there are some point that I'm not sure of yet, like when the user select a column name that is not exists, do we need to raise an exception or ignore it. I'd wrote a WIP proposal for this https://github.com/php/php-src/pull/25514 waiting your thoughts about it. Best regards, Hassan

« previous php.internals (#133179) next »