本文整理汇总了PHP中sqlsrv_field_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlsrv_field_metadata函数的具体用法?PHP sqlsrv_field_metadata怎么用?PHP sqlsrv_field_metadata使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlsrv_field_metadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param resource handle
*/
public function __construct($result, \util\TimeZone $tz = null)
{
$fields = [];
if (is_resource($result)) {
foreach (sqlsrv_field_metadata($result) as $meta) {
$fields[$meta['Name']] = $meta;
}
}
parent::__construct($result, $fields, $tz);
}
示例2: __construct
/**
* Constructor
*
* @param resource handle
*/
public function __construct($result, TimeZone $tz = NULL)
{
$fields = array();
if (is_resource($result)) {
foreach (sqlsrv_field_metadata($result) as $meta) {
$fields[$meta['Name']] = $meta;
}
}
parent::__construct($result, $fields, $tz);
}
示例3: getResultFields
public function getResultFields()
{
if (empty($this->resultFields)) {
$fields = sqlsrv_field_metadata($this->resource);
if ($fields) {
foreach ($fields as $key => $value) {
$this->resultFields[$key] = array("name" => $value["Name"], "type" => $value["Type"]);
}
}
}
return $this->resultFields;
}
示例4: field_data
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field) {
$F = new stdClass();
$F->name = $field['Name'];
$F->type = $field['Type'];
$F->max_length = $field['Size'];
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
示例5: getFields
/**
* Returns an array of fields according to columns in the result.
*
* @return \Bitrix\Main\Entity\ScalarField[]
*/
public function getFields()
{
if ($this->resultFields == null) {
$this->resultFields = array();
if (is_resource($this->resource)) {
$fields = sqlsrv_field_metadata($this->resource);
if ($fields && $this->connection) {
$helper = $this->connection->getSqlHelper();
foreach ($fields as $value) {
$name = $value["Name"] != '' ? $value["Name"] : uniqid();
$parameters = array("size" => $value["Size"], "scale" => $value["Scale"]);
$this->resultFields[$name] = $helper->getFieldByColumnType($name, $value["Type"], $parameters);
}
}
}
}
return $this->resultFields;
}
示例6: result_mssqlnative
public function result_mssqlnative($queryresult = false)
{
$this->m_cursor = 0;
$this->m_rows = array();
$this->m_num_fields = sqlsrv_num_fields($queryresult);
$this->m_field_meta = sqlsrv_field_metadata($queryresult);
while ($row = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC)) {
if ($row !== null) {
foreach ($row as $k => $v) {
if (is_object($v) && method_exists($v, 'format')) {
$row[$k] = $v->format("Y-m-d\\TH:i:s\\Z");
}
}
$this->m_rows[] = $row;
//read results into memory, cursors are not supported
}
}
$this->m_row_count = sizeof($this->m_rows);
}
示例7: GetFields
function GetFields()
{
$_fields = array();
$_result = sqlsrv_query($this->_Link, $this->SelectCommand);
$data = sqlsrv_field_metadata($_result);
//echo "<pre>";
//print_r($data);
foreach ($data as $key => $value) {
$_field = array("Name" => $value['Name'], "Type" => $value['Type'], "Not_Null" => 0);
array_push($_fields, $_field);
}
return $_fields;
/*while($_prop = sqlsrv_field_metadata($_result))
{
$_field = array("Name"=>$_prop['Name'],"Type"=>$_prop['Type'],"Not_Null"=>0);
array_push($_fields,$_field);
}
return $_fields;*/
}
示例8: sql_field_name
function sql_field_name($sqltype, $result, $i)
{
if ($sqltype == 'mysql') {
if (class_exists('mysqli_result')) {
$z = $result->fetch_field();
return $z->name;
} elseif (function_exists('mysql_field_name')) {
return mysql_field_name($result, $i);
}
} elseif ($sqltype == 'mssql') {
if (function_exists('sqlsrv_field_metadata')) {
$metadata = sqlsrv_field_metadata($result);
if (is_array($metadata)) {
$metadata = $metadata[$i];
}
if (is_array($metadata)) {
return $metadata['Name'];
}
} elseif (function_exists('mssql_field_name')) {
return mssql_field_name($result, $i);
}
} elseif ($sqltype == 'pgsql') {
return pg_field_name($result, $i);
} elseif ($sqltype == 'oracle') {
return oci_field_name($result, $i + 1);
} elseif ($sqltype == 'sqlite3') {
return $result->columnName($i);
} elseif ($sqltype == 'sqlite') {
return sqlite_field_name($result, $i);
} elseif ($sqltype == 'odbc') {
return odbc_field_name($result, $i + 1);
} elseif ($sqltype == 'pdo') {
$res = $result->getColumnMeta($i);
return $res['name'];
}
}
示例9: _fetch
/**
* @brief 결과를 fetch
**/
function _fetch($result)
{
if (!$this->isConnected() || $this->isError() || !$result) {
return;
}
$c = sqlsrv_num_fields($result);
$m = null;
$output = array();
while (sqlsrv_fetch($result)) {
if (!$m) {
$m = sqlsrv_field_metadata($result);
}
unset($row);
for ($i = 0; $i < $c; $i++) {
$row->{$m[$i]['Name']} = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING('utf-8'));
}
$output[] = $row;
}
if (count($output) == 1) {
return $output[0];
}
return $output;
}
示例10: FetchField
function FetchField($fieldOffset = -1)
{
if ($this->connection->debug) {
error_log("<hr>fetchfield: {$fieldOffset}, fetch array: <pre>" . print_r($this->fields, true) . "</pre> backtrace: " . adodb_backtrace(false));
}
if ($fieldOffset != -1) {
$this->fieldOffset = $fieldOffset;
}
/*$arrKeys = array_keys($this->fields);
if(array_key_exists($this->fieldOffset,$arrKeys) && !array_key_exists($arrKeys[$this->fieldOffset],$this->fields)) {
$f = false;
} else {
$f = new ADOFetchObj();
$f->name = $arrKeys[$this->fieldOffset];
if($fieldOffset == -1) $this->fieldOffset++;
}
if (empty($f)) {
$f = false;//PHP Notice: Only variable references should be returned by reference
}*/
$fieldMeta = @sqlsrv_field_metadata($this->_queryID);
$f = new ADOFieldObject();
$f->name = $fieldMeta[$this->fieldOffset]['Name'];
$f->type = $fieldMeta[$this->fieldOffset]['Type'];
$f->max_length = $fieldMeta[$this->fieldOffset]['Size'];
return $f;
}
示例11: get_rs_metadata
function get_rs_metadata($stmt)
{
$metadatas = sqlsrv_field_metadata($stmt);
$metadataHash = array();
foreach ($metadatas as $metadata) {
$metadataHash[$metadata['Name']] = $metadata['Type'];
}
return $metadataHash;
}
示例12: getResultColumns
/**
* Returns metadata for all columns in a result set.
* @return array
*/
public function getResultColumns()
{
$columns = [];
foreach ((array) sqlsrv_field_metadata($this->resultSet) as $fieldMetadata) {
$columns[] = ['name' => $fieldMetadata['Name'], 'fullname' => $fieldMetadata['Name'], 'nativetype' => $fieldMetadata['Type']];
}
return $columns;
}
示例13: _FetchField
function _FetchField($fieldOffset = -1)
{
$_typeConversion = array(-155 => 'datetimeoffset', -154 => 'time', -152 => 'xml', -151 => 'udt', -11 => 'uniqueidentifier', -10 => 'ntext', -9 => 'nvarchar', -8 => 'nchar', -7 => 'bit', -6 => 'tinyint', -5 => 'bigint', -4 => 'image', -3 => 'varbinary', -2 => 'timestamp', -1 => 'text', 1 => 'char', 2 => 'numeric', 3 => 'decimal', 4 => 'int', 5 => 'smallint', 6 => 'float', 7 => 'real', 12 => 'varchar', 91 => 'date', 93 => 'datetime');
$fa = @sqlsrv_field_metadata($this->_queryID);
if ($fieldOffset != -1) {
$fa = $fa[$fieldOffset];
}
$false = false;
if (empty($fa)) {
$f = false;
//PHP Notice: Only variable references should be returned by reference
} else {
// Convert to an object
$fa = array_change_key_case($fa, CASE_LOWER);
$fb = array();
if ($fieldOffset != -1) {
$fb = array('name' => $fa['name'], 'max_length' => $fa['size'], 'column_source' => $fa['name'], 'type' => $_typeConversion[$fa['type']]);
} else {
foreach ($fa as $key => $value) {
$fb[] = array('name' => $value['name'], 'max_length' => $value['size'], 'column_source' => $value['name'], 'type' => $_typeConversion[$value['type']]);
}
}
$f = (object) $fb;
}
return $f;
}
示例14: _getColumns
private function _getColumns($tsql, Zend_Db_Adapter_Sqlsrv $db)
{
$conn = $db->getConnection();
$stmt = sqlsrv_prepare($conn, $tsql);
$data = sqlsrv_field_metadata($stmt);
$cols = array();
foreach ($data as $col) {
$cols[] = $col['Name'];
}
return $cols;
}
示例15: _fetchRowAssoc
/**
* Low level handling getting a row from a result set; automatically
* makes all fetched values strings, just like the other PHP db functions.
* We have to do this since the sqlsrv extension returns row values in thier
* native types, which causes problems with how we handle things.
*
* @param resource $result
* @return array
*/
private function _fetchRowAssoc($result)
{
if (!is_resource($result)) {
return false;
}
$row = array();
$fieldnames = $this->getFieldsArray($result);
$fieldMetaData = sqlsrv_field_metadata($result);
if (sqlsrv_fetch($result)) {
for ($i = 0; $i < sqlsrv_num_fields($result); $i++) {
if ($fieldMetaData[$i]['Type'] == -9 || $fieldMetaData[$i]['Type'] >= SQLSRV_SQLTYPE_NVARCHAR(1) && $fieldMetaData[$i]['Type'] <= SQLSRV_SQLTYPE_NVARCHAR(8000) || $fieldMetaData[$i]['Type'] >= SQLSRV_SQLTYPE_NCHAR(1) && $fieldMetaData[$i]['Type'] <= SQLSRV_SQLTYPE_NCHAR(8000) || $fieldMetaData[$i]['Type'] == SQLSRV_SQLTYPE_NVARCHAR('max') || $fieldMetaData[$i]['Type'] == SQLSRV_SQLTYPE_NCHAR('max')) {
$row[$fieldnames[$i]] = iconv("utf-16le", "utf-8", sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY)));
} else {
$row[$fieldnames[$i]] = sqlsrv_get_field($result, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
}
}
} else {
sqlsrv_free_stmt($result);
}
return $row;
}