php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49856 SHOW COLUMNS FROM... return weird result set
Submitted: 2009-10-13 02:23 UTC Modified: 2009-12-17 01:00 UTC
From: joao at jjmf dot com Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.3.0 OS: CentOS 5.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joao at jjmf dot com
New email:
PHP Version: OS:

 

 [2009-10-13 02:23 UTC] joao at jjmf dot com
Description:
------------
When executing the query "SHOW COLUMNS FROM table" it returns weird 
results.
Database: MySQL.
I think it's something related to CentOS 5.3 since I got this problem 
after migrating from Ubuntu. This never happened in Ubuntu. 

Reproduce code:
---------------
---
From manual page: pdostatement.fetch#Descrição
---
$pdo = new PDO(
    'mysql:host=localhost;dbname=MYDB', 'MYUSER', 'MYPASS',
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
);


$sql = "SHOW COLUMNS FROM tablename";
$sth = $pdo->prepare($sql);
$sth->execute();

/* Exercise PDOStatement::fetch styles */
print("PDO::FETCH_ASSOC: ");
print("Return next row as an array indexed by column name\n");
$result = $sth->fetch(PDO::FETCH_ASSOC);
print_r($result);
print("\n");


Expected result:
----------------
For each column an array like:
[Field] => 'id_user'
[Type] => 'int(11) unsigned'
[Null] => 'NO'
[Key] => 'PRI'
[Default] => null
[Extra] => 'auto_increment'

Actual result:
--------------
For each column an array like:
[Field] => id_user
[COLUMN_TYPE] => int(11) unsigned 
[COLUMNS] => NO 
[] => 
[def] => auto_increment 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-04 17:09 UTC] uw@php.net
What MySQL version are you using?
 [2009-11-04 17:22 UTC] joao at jjmf dot com
Mysql version is 5.0.77-3.el5
 [2009-11-04 18:43 UTC] uw@php.net
Sorry, can't reproduce. Works fine for me with PHP 5.3.2-dev if either using libmysql or mysqlnd.

array(6) {
  ["Field"]=>
  string(2) "id"
  ["Type"]=>
  string(7) "int(11)"
  ["Null"]=>
  string(2) "NO"
  ["Key"]=>
  string(3) "PRI"
  ["Default"]=>
  string(1) "0"
  ["Extra"]=>
  string(0) ""
}
array(1) {
  ["_version"]=>
  string(19) "5.0.77-community-nt"
}


Maybe others can reproduce, if you provide the table structure. Does SHOW COLUMNS work properly on the mysql prompt? 
 [2009-11-04 18:43 UTC] uw@php.net
Sorry, can't reproduce. Works fine for me with PHP 5.3.2-dev if either using libmysql or mysqlnd.

array(6) {
  ["Field"]=>
  string(2) "id"
  ["Type"]=>
  string(7) "int(11)"
  ["Null"]=>
  string(2) "NO"
  ["Key"]=>
  string(3) "PRI"
  ["Default"]=>
  string(1) "0"
  ["Extra"]=>
  string(0) ""
}
array(1) {
  ["_version"]=>
  string(19) "5.0.77-community-nt"
}


Maybe others can reproduce, if you provide the table structure. Does SHOW COLUMNS work properly on the mysql prompt? 
 [2009-12-17 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 16:01:37 2025 UTC