ID: 42756
Updated by: [EMAIL PROTECTED]
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