Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

PDOStatement::getColumnMeta

SQL Server 2008 R2

Retrieves metadata for a column.

array PDOStatement::getColumnMeta ( $column );

$conn: (Integer) The zero-based number of the column whose metadata you want to retrieve.

An associative array (key and value) containing the metadata for the column. See the Remarks section for a description of the fields in the array.

The following table describes the fields in the array returned by getColumnMeta.

NAME

VALUES

native_type

Specifies the PHP type for column. Always string.

driver:decl_type

Specifies 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 is not returned by PDOStatement::getColumnMeta.

flags

Specifies the flags set for this column. Always 0.

name

Specifies the name of the column in the database.

table

Specifies the name of the table that contains the column in the database. Always blank.

len

Specifies the column length.

precision

Specifies the numeric precision of this column.

pdo_type

Specifies the type of this column as represented by the PDO::PARAM_* constants. Always PDO::PARAM_STR (2).

Support for PDO was added in version 2.0 of the Microsoft Drivers for PHP for SQL Server.

<?php
$database = "AdventureWorks";
$server = "(local)";
$conn = new PDO( "sqlsrv:server=$server ; Database = $database", "", "");

$stmt = $conn->query("select * from Person.ContactType");
$metadata = $stmt->getColumnMeta(2);
var_dump($metadata);

print $metadata['sqlsrv:decl_type'] . "\n";
print $metadata['native_type'] . "\n";
print $metadata['name'];
?>

Reference

Other Resources

PDO

Community Additions

ADD
Show:
© 2015 Microsoft