[PATCH] PDO::FETCH_2D
| From: | Hans-Peter Oeri | Date: | Mon, 19 Nov 2007 20:09:36 +0000 |
| Subject: | [PATCH] PDO::FETCH_2D | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-33329@lists.php.net to get a copy of this message | ||
Hi!
As per my rfd from 2007-11-14, I prepared a FETCH_2D (work title) patch
- where a row result consists of a two-dimensional hash, the first
dimension being the table name, the second the field name.
Summary:
I propose to rearrange FETCH mode constants, such that FETCH_NUM,
FETCH_ASSOC and (new) FETCH_2D are bitwise combineable:
FETCH_ASSOC | FETCH_NUM = FETCH_BOTH
FETCH_2D | FETCH_NUM = FETCH_2D_NUM
FETCH_2D is the "core" of my proposal. It's like the
ATTR_FETCH_TABLE_NAMES, enhanced in arrays. Columns are to be found on
the second level:
$result[tablename][columname]
Columns that don't result from a table are added to a "null base" (work
title). The default "null base" is the first level array:
$result[computedcolumn]
The connection attribute ATTR_2D_NULLBASE (work title) defines an
alternative "null base":
$result[nullbase][computedcolumn]
FETCH_2D should be combineable with FETCH_ASSOC and/or FETCH_NUM. The
corresponding entries are added to the "null base" (a reference).
Status:
The attached patch against CVS PHP_5_3 supports the described
functionality with pdo_mysql and pdo_firebird (my primary).
Please let me know if I'm on a totally wrong path.
HPO