|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-25 10:57 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 13:00:01 2025 UTC |
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));