Easy Tutorial
❮ Func Array Chunk Php Preg_Match ❯

PDOStatement::getColumnMeta

PHP PDO Reference Manual

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 the result set, indexed from 0, as an associative array.

Note: This function is experimental. The behavior of this function, including its name and related documentation, may change without notice in future releases of PHP. Use this function at your own risk.

Note: Not all PDO drivers support PDOStatement::getColumnMeta().


Parameters

column


Return Value

Returns an associative array containing the metadata for an individual column, including the following values:

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 a function result, 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 this column. Typically -1 for types other than floating point numbers.
precision The numeric precision of this column. Typically 0 for types other than floating point numbers.
pdo_type The column type represented by PDO::PARAM_* constants.

Examples

Retrieving Column Metadata

The following example demonstrates the result of retrieving metadata for a single column generated by a function (COUNT) in PDO_SQLITE.

<?php
$select = $DB->query('SELECT COUNT(*) FROM fruit');
$meta = $select->getColumnMeta(0);
var_dump($meta);
?>

Output of the above example:

array(6) {
  ["native_type"]=>
  string(7) "integer"
  ["flags"]=>
  array(0) {
  }
  ["name"]=>
  string(8) "COUNT(*)"
  ["len"]=>
  int(-1)
  ["precision"]=>
  int(0)
  ["pdo_type"]=>
  int(2)
}

PHP PDO Reference Manual

❮ Func Array Chunk Php Preg_Match ❯