I have innodb table with the following scheme, running MySQL 5.5:
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`category_id` int(10) unsigned DEFAULT NULL,
`uuid` varchar(36) NOT NULL,
I am trying to use PDOStatement::getColumnMeta to get id
column type, but it gives wrong data:
array(3) {
[0]=>
array(7) {
["native_type"]=>
string(4) "LONG"
["flags"]=>
array(2) {
[0]=>
string(8) "not_null"
[1]=>
string(11) "primary_key"
}
["table"]=>
string(7) "entries"
["name"]=>
string(2) "id"
["len"]=>
int(10)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
[1]=>
array(7) {
["native_type"]=>
string(4) "LONG"
["flags"]=>
array(1) {
[0]=>
string(12) "multiple_key"
}
["table"]=>
string(7) "entries"
["name"]=>
string(11) "category_id"
["len"]=>
int(10)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
[2]=>
array(7) {
["native_type"]=>
string(10) "VAR_STRING"
["flags"]=>
array(1) {
[0]=>
string(8) "not_null"
}
["table"]=>
string(7) "entries"
["name"]=>
string(4) "uuid"
["len"]=>
int(108)
["precision"]=>
int(0)
["pdo_type"]=>
int(2)
}
}
PHP code as requested:
$select = $db
->query("
SELECT
`id`,
`category_id`,
`uuid`
FROM
`entries`
LIMIT 1;
;
");
$meta = [];
for($i = 0, $j = $select->columnCount(); $i < $j; $i++)
{
$meta[] = $select->getColumnMeta($i);
}