cvs: pear /LiveUser_Admin/Storage PDO.php

From: Date: Mon, 27 Mar 2006 09:33:34 +0000
Subject: cvs: pear /LiveUser_Admin/Storage PDO.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39366@lists.php.net to get a copy of this message
lsmith Mon Mar 27 09:33:34 2006 UTC Modified files: /pear/LiveUser_Admin/Storage PDO.php Log: - fixed queryAll() (bug #7213) http://cvs.php.net/viewcvs.cgi/pear/LiveUser_Admin/Storage/PDO.php?r1=1.6&r2=1.7&diff_format=u Index: pear/LiveUser_Admin/Storage/PDO.php diff -u pear/LiveUser_Admin/Storage/PDO.php:1.6 pear/LiveUser_Admin/Storage/PDO.php:1.7 --- pear/LiveUser_Admin/Storage/PDO.php:1.6 Tue Mar 14 13:11:56 2006 +++ pear/LiveUser_Admin/Storage/PDO.php Mon Mar 27 09:33:33 2006 @@ -57,7 +57,7 @@ * @author Bjoern Kraus <krausbn@php.net> * @copyright 2002-2006 Markus Wolff * @license http://www.gnu.org/licenses/lgpl.txt - * @version CVS: $Id: PDO.php,v 1.6 2006/03/14 13:11:56 lsmith Exp $ + * @version CVS: $Id: PDO.php,v 1.7 2006/03/27 09:33:33 lsmith Exp $ * @link http://pear.php.net/LiveUser_Admin */ @@ -311,7 +311,7 @@ { try { $stmt = $this->dbc->query($query); - $result = $stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_COLUMN); + $result = $stmt->fetchAll(PDO::FETCH_COLUMN); } catch (PDOException $e) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array( @@ -345,7 +345,28 @@ { try { $stmt = $this->dbc->query($query); - $result = $stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_COLUMN|PDO::FETCH_GROUP); + $fetchmode = $rekey ? PDO::FETCH_ASSOC|PDO::FETCH_GROUP : PDO::FETCH_ASSOC; + $result = $stmt->fetchAll($fetchmode); + if ($rekey && !empty($result)) { + $make_scalar = (count(reset(reset($result))) == 1); + if ($group) { + if ($make_scalar) { + foreach ($result as $group => $array) { + foreach ($array as $key => $value) { + $result[$group][$key] = reset($value); + } + } + } + } elseif ($make_scalar) { + foreach ($result as $group => $array) { + $result[$group] = reset(end($array)); + } + } else { + foreach ($result as $group => $array) { + $result[$group] = end($array); + } + } + } } catch (PDOException $e) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array(

« previous php.pear.cvs (#39366) next »