Bug #57285 [Opn->Nab]: fetchAll PDO::FETCH_GROUP|PDO::FETCH_COLUMN,2

From: Date: Sat, 18 Jun 2016 14:30:00 +0000
Subject: Bug #57285 [Opn->Nab]: fetchAll PDO::FETCH_GROUP|PDO::FETCH_COLUMN,2
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201717@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=57285&edit=1 ID: 57285 Updated by: cmb@php.net Reported by: jakoch at web dot de Summary: fetchAll PDO::FETCH_GROUP|PDO::FETCH_COLUMN,2 -Status: Open +Status: Not a bug Type: Bug -Package: PDO +Package: *General Issues PHP Version: 5.1.2 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > this might be a bug. It doesn't appear so. > How to group values by the second column ? Specify the column index as $fetch_argument. > $stmt->fetchALL(PDO::FETCH_COLUMN,1|PDO::FETCH_GROUP); Should be $stmt->fetchALL(PDO::FETCH_COLUMN|PDO::FETCH_GROUP,1); Previous Comments: ------------------------------------------------------------------------ [2007-01-10 11:41:32] arne dot anka at gmx dot net same here: $query="SELECT col1,col2 FROM table"; $db->query($query)->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP); result: Array ( [1] => Array ( [0] => firmaA ) [2] => Array ( [0] => firmaB ) [3] => Array ( [0] => firmaC ) [4] => Array ( [0] => firmaD ) ) expected: Array ( [1] => firmaA [2] => firmaB [3] => firmaC [4] => firmaD ) ------------------------------------------------------------------------ [2006-10-07 15:12:25] jakoch at web dot de actual result is array empty ------------------------------------------------------------------------ [2006-10-07 15:05:22] jakoch at web dot de Description: ------------ Hello, this might be a bug. I'm trying to fetch an associative array grouped by the values of a specified column. In my case the column 'name'. How to group values by the second column ? Expected result: ---------------- $res = $stmt->fetchALL(PDO::FETCH_COLUMN,1|PDO::FETCH_GROUP); array 'configs' => array 'submodule_id' => '17' (length=2) 'name' => 'configs' (length=7) 'file_name' => 'configs.module.php' (length=18) 'class_name' => 'module_admin_configs' (length=20) Actual result: -------------- $res = $stmt->fetchALL(PDO::FETCH_NAMED); Return: array 0 => array 'submodule_id' => '17' (length=2) 'name' => 'configs' (length=7) 'file_name' => 'configs.module.php' (length=18) 'class_name' => 'module_admin_configs' (length=20) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=57285&edit=1

« previous php.bugs (#201717) next »