Pdostatement Getcolumnmeta
# PDOStatement::getColumnMeta
[PHP PDO Reference](#)
PDOStatement::getColumnMeta β Returns metadata for a column in a result set (PHP 5 >= 5.1.0, PECL pdo >= 0.2.0)
* * *
## Description
### Syntax
array PDOStatement::getColumnMeta ( int $column )
Retrieves metadata for a column in a result set, indexed starting from 0, as an associative array.
**Note:** This function is experimental. The behavior of this function, including its name and its documentation, may be modified without notice in future PHP releases. Use this function at your own risk.
**Note:** Not all PDO drivers support PDOStatement::getColumnMeta().
* * *
## Parameters
**column**
The column in the result set, indexed starting from 0.
* * *
## Return Value
Returns an associative array containing the following values representing the metadata for a single column:
**Column Metadata**
| Name | Value |
| --- | --- |
| _native_type_ | The PHP native type used to represent the column value. |
| _driver:decl_type_ | The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value cannot be returned by **PDOStatement::getColumnMeta()**. |
| _flags_ | Any flags set for this column. |
| _name_ | The name of the column as returned by the database. |
| _table_ | The name of the table for this column as returned by the database. |
| _len_ | The length of the column. Usually _-1_ except for floating-point decimals. |
| _precision_ | The numeric precision of the column. Usually _0_ except for floating-point decimals. |
| _pdo_type_ | The column type, represented by the _PDO::PARAM_*_ constants. |
* * *
## Examples
### Retrieving column metadata
The following example shows the result of retrieving metadata for a single column generated by a function (COUNT) in a PDO_SQLITE.
```php
query('SELECT COUNT(*) FROM fruit');
$meta = $select->getColumnMeta(0);
var_dump($meta);
?>
The above example will output:
array(6) {
=>
string(7) "integer"
=>
array(0) {
}
=>
string(8) "COUNT(*)"
=>
int(-1)
=>
int(0)
=>
int(2)
}
* * PHP PDO Reference](#)
[](#)(#)
(#)[](#)
YouTip