Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42467 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82349 invoked from network); 3 Jan 2009 20:44:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2009 20:44:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=patchnow@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patchnow@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.78.27 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: patchnow@gmail.com X-Host-Fingerprint: 74.125.78.27 ey-out-2122.google.com Received: from [74.125.78.27] ([74.125.78.27:37048] helo=ey-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/2D-01547-02ECF594 for ; Sat, 03 Jan 2009 15:44:17 -0500 Received: by ey-out-2122.google.com with SMTP id 25so1103018eya.59 for ; Sat, 03 Jan 2009 12:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=CM3daqHeaCKhYyOC1VLgwjeILq/16J4gYa8HgIGNQ9s=; b=dd62TM/3Y/Kw93HNXw6e1fyjBYXQ+FFX3BNfXnzxAg8vIIKmBE8NjiU2PqRMaVpAa2 UI9wSGbcEvXERnfHSMtjiGjCzxg+snn2ssvLG/IlwPgd9s/ODi8I3klJnkm1f7Mn8ipQ SQtIIexSkDGzUeiC6idEje660kZTvF7SGDPhQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=luSP0cN9u5SMYget1DzLfeKU5M927/ldncXph8cINv+GfYKjsrkRZrawmHo22osoHq 6PeVQfyw2Li2VqFK/1baVsQIbHQ5xkgZC21OBFkQWgDvjrTen7ADLSFLaYLeAwqizjXc nTmeIr2u3Y8ljLcyZuiC6D3LffxIwQaZw6kMM= Received: by 10.210.59.14 with SMTP id h14mr8118454eba.16.1231015453055; Sat, 03 Jan 2009 12:44:13 -0800 (PST) Received: from ?192.168.0.80? (xdsl-78-34-135-192.netcologne.de [78.34.135.192]) by mx.google.com with ESMTPS id 24sm1892535eyx.35.2009.01.03.12.44.11 (version=SSLv3 cipher=RC4-MD5); Sat, 03 Jan 2009 12:44:12 -0800 (PST) Message-ID: <495FCE1A.2000904@gmail.com> Date: Sat, 03 Jan 2009 21:44:10 +0100 User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: PDO: table name of field in SQLite #42589 and a new fetch style FETCH_ASSOC_TREE From: patchnow@gmail.com (Oskar Eisemuth) Hi Receiving the table name for an column is quite useful. It is not possible for all PDO database drivers to support this functionally, still at least the SQLite version could support it when Bug #42589 is resolved. ATTR_FETCH_TABLE_NAMES should be added to SQLite too. Currently we have 2(3) ways to get a table name for a column. PDOStatement -> getColumnMeta PDO::ATTR_FETCH_TABLE_NAMES (Not in the SQLite patch) A patch to support new fetch modes ( FETCH_2D) by Hans-Peter Oeri It would be nice if something like FETCH_2D would be possible, so let's purpose a fourth way in the spirit of Hans-Peters patch. :o) PDO::FETCH_ASSOC_TREE Using the column key to build a hierarchical tree structure by using the dot as delimiter for the keys. Together with PDO::ATTR_FETCH_TABLE_NAMES this would result into mostly the same functionality as FETCH_2D | FETCH_ASSOC as in the FETCH_2D patch. Joining with different tables (with same column names) without doing any manually aliasing would end up to be quite easy: SELECT test1.*, test2.* FROM test1 LEFT JOIN test2 ... And could then post processed to get the relations right and/or converting to objects quite easily. FETCH_CLASS_TREE would be even nicer but there isn't a good way to do that. (Would need new interfaces to connect keys/table names to specific classes) When ATTR_FETCH_TABLE_NAMES isn't support it is still possible to manually redirect every field by an alias name in the SQL string and benefit from the automatically converting of result rows into a tree like structure. Surely FETCH_ASSOC_TREE could be written at script level, I do think the "split at dot and traversing" part is better done in the PDO extension and comparing to FETCH_2D it only really touches PDO fetch without any need to change the PDO drivers. (But could be optimized later to skip parts of ATTR_FETCH_TABLE_NAMES in the driver) So what do you think? ------ Oskar Eisemuth