Re: [PATCH] PDO::FETCH_2D

From: Date: Mon, 19 Nov 2007 23:47:09 +0000
Subject: Re: [PATCH] PDO::FETCH_2D
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-33343@lists.php.net to get a copy of this message
On 19.11.2007, at 21:09, Hans-Peter Oeri wrote:
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]
Not sure how real world useful this is. What I have seen more is a need to build tree style structures. This would require knowing the FK's or allowing the user to specify the tree structure they want. This sort of thing is supported by C#'s LINQ.
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]
Why not use an empty string aka null casted to a string. That way you will never run into a situation where someone has called their table "nullbase". It will also make it immediatly clear to anyone that this array key is special. regards, Lukas

« previous php.internals (#33343) next »