PDOStatement::getColumnMeta
PDOStatement::getColumnMeta — Returns metadata in a column in the result set (PHP 5 >= 5.1.0, PECL pdo >= 0.2.0)
illustrate
grammar
array PDOStatement::getColumnMeta ( int $column )
Retrieve metadata of a column indexed with 0 in the result set as an associative array.
Note: This function is experimental. The representation of this function, including the name and its related documents, may be modified without notification in future PHP releases. Use of this function at your own risk.
Note: Not all PDO drivers support itPDOStatement::getColumnMeta()
。
parameter
column
- The column indexed with 0 is started in the result set.
Return value
Returns an associative array containing the following values representing the metadata of a separate column:
Metadata for columns
Name
native_type
driver:decl_type SQL type used to represent column values in the database. If the column in the result set is the result of a function, the value cannot be returned by PDOStatement::getColumnMeta().
flags �
name
table
len � Except for floating point decimals, usually -1
precision Except for floating point decimals, it is usually 0.
pdo_type �
Example
Retrieve metadata for columns
The following example shows the result of retrieving a metadata generated by a function (COUNT) in a PDO_SQLITE.
<?php $select = $DB->query('SELECT COUNT(*) FROM fruit'); $meta = $select->getColumnMeta(0); var_dump($meta); ?>
The above example output:
array(6) { ["native_type"]=> string(7) "integer" ["flags"]=> array(0) { } ["name"]=> string(8) "COUNT(*)" ["len"]=> int(-1) ["precision"]=> int(0) ["pdo_type"]=> int(2) }
Summarize
The above is the entire content of this article. I hope that the content of this article has certain reference value for your study or work. Thank you for your support. If you want to know more about it, please see the relevant links below