#42756 [Opn->Fbk]: getColumnMeta() flag primary_key disappears when combining JOIN and ORDER BY

From: Date: Fri, 12 Oct 2007 19:11:43 +0000
Subject: #42756 [Opn->Fbk]: getColumnMeta() flag primary_key disappears when combining JOIN and ORDER BY
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118489@lists.php.net to get a copy of this message
ID: 42756 Updated by: mj@php.net Reported By: jens dot ljungblad at gmail dot com -Status: Open +Status: Feedback Bug Type: PDO related Operating System: Win XP PHP Version: 5.2.4 New Comment: The script below gives me the primary_key for both fields. Can you please try it on your installation? Thanks! mysql> describe test; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | dummy | varchar(255) | NO | PRI | | | +-------+--------------+------+-----+---------+-------+ 1 row in set (0.00 sec) mysql> <?php $dbh = new PDO("mysql:host=localhost;dbname=database", $user, $password); $result = $dbh->query("SELECT * FROM test t1 LEFT JOIN test t2 ON t1.dummy = t2.dummy ORDER BY t1.dummy"); print_r($result->getColumnMeta(0)); print_r($result->getColumnMeta(1)); Previous Comments: ------------------------------------------------------------------------ [2007-09-25 10:57:18] jens dot ljungblad at gmail dot com Description: ------------ When doing a joined query with ORDER BY, the flag 'primary_key' disappears from the getColumnMeta() data. It is available when doing a JOIN and when doing an ORDER BY, but not when you combine the two. Reproduce code: --------------- <?php $pdo = new PDO(); $pdo->query('SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id ORDER BY table1.id'); foreach ($pdo as $row) { for ($i=0; $meta = $pdo->getColumnMeta($i); $i++) { print_r($meta); } } ?> Expected result: ---------------- I expect columns that are primary keys to have the 'primary_key' flag: [flags] => Array ( [0] => not_null [1] => primary_key ) Actual result: -------------- The primary_key flag is missing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42756&edit=1

« previous php.bugs (#118489) next »