IT. Expert System.

PHP

Metadata


Metadata

A MySQL result set contains metadata. The metadata describes the columns found in the result set. All metadata send by MySQL is accessible through the mysqli interface. The extension performs no or negligible changes to the information it receives. Differences between MySQL server versions are not aligned.

Meta data is access through the mysqli_result interface.

Example #1 Accessing result set meta data

<?php
$mysqli 
= new mysqli("example.com""user""password""database");
if (
$mysqli->connect_errno) {
    echo 
"Failed to connect to MySQL: (" $mysqli->connect_errno ") " $mysqli->connect_error;
}

$res $mysqli->query("SELECT 1 AS _one, 'Hello' AS _two FROM DUAL");
var_dump($res->fetch_fields());
?>

The above example will output:

 array(2) { [0]=> object(stdClass)#3 (13) {  ["name"]=>  string(4) "_one"  ["orgname"]=>  string(0) ""  ["table"]=>  string(0) ""  ["orgtable"]=>  string(0) ""  ["def"]=>  string(0) ""  ["db"]=>  string(0) ""  ["catalog"]=>  string(3) "def"  ["max_length"]=>  int(1)  ["length"]=>  int(1)  ["charsetnr"]=>  int(63)  ["flags"]=>  int(32897)  ["type"]=>  int(8)  ["decimals"]=>  int(0) } [1]=> object(stdClass)#4 (13) {  ["name"]=>  string(4) "_two"  ["orgname"]=>  string(0) ""  ["table"]=>  string(0) ""  ["orgtable"]=>  string(0) ""  ["def"]=>  string(0) ""  ["db"]=>  string(0) ""  ["catalog"]=>  string(3) "def"  ["max_length"]=>  int(5)  ["length"]=>  int(5)  ["charsetnr"]=>  int(8)  ["flags"]=>  int(1)  ["type"]=>  int(253)  ["decimals"]=>  int(31) } } 

Prepared statements

Meta data of result sets created using prepared statements are accessed the same way. A suitable mysqli_result handle is returned by mysqli_stmt_result_metadata().

Example #2 Prepared statements metadata

<?php
$stmt 
$mysqli->prepare("SELECT 1 AS _one, 'Hello' AS _two FROM DUAL");
$stmt->execute();
$res $stmt->result_metadata();
var_dump($res->fetch_fields());
?>

See also



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 572 / . Delta: 0.02870 с