|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
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?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?