本文整理汇总了PHP中mssql_fetch_field函数的典型用法代码示例。如果您正苦于以下问题:PHP mssql_fetch_field函数的具体用法?PHP mssql_fetch_field怎么用?PHP mssql_fetch_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mssql_fetch_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetFields
function GetFields()
{
$_fields = array();
$_result = mssql_query($this->SelectCommand, $this->_Link);
while ($_prop = mssql_fetch_field($_result)) {
$_field = array("Name" => $_prop->name, "Type" => $_prop->type, "Not_Null" => 0);
array_push($_fields, $_field);
}
return $_fields;
}
示例2: __construct
/**
* Constructor
*
* @param resource handle
*/
public function __construct($result, TimeZone $tz = NULL)
{
$fields = array();
if (is_resource($result)) {
for ($i = 0, $num = mssql_num_fields($result); $i < $num; $i++) {
$field = mssql_fetch_field($result, $i);
$fields[$field->name] = $field->type;
}
}
parent::__construct($result, $fields, $tz);
}
示例3: field_data
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
while ($field = mssql_fetch_field($this->result_id)) {
$F = new stdClass();
$F->name = $field->name;
$F->type = $field->type;
$F->max_length = $field->max_length;
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
示例4: __get
/**
* Dynamic Get Function Override
*
* @param $name
* A string containing the name of the property to get.
* @return
* Value of the property.
*/
public function __get($propertyName)
{
// global $firePHP;
if ($propertyName == 'columns') {
if (!isset($this->_columns)) {
//---- Get Columns
$this->_columns = new anvilCollection();
$i = 0;
// $sql = 'SHOW COLUMNS FROM ';
while ($i < mssql_num_fields($this->result)) {
$meta = mssql_fetch_field($this->result, $i);
if ($meta) {
// $firePHP->_log($meta);
$newColumn = new anvilData_mssql_Column($meta->name, $meta->type);
$this->_columns->add($newColumn);
}
$i++;
}
}
return $this->_columns;
} else {
return parent::__get($propertyName);
}
}
示例5: list_fields
public function list_fields()
{
$field_names = array();
while ($field = mssql_fetch_field($this->result)) {
$field_names[] = $field->name;
}
return $field_names;
}
示例6: getColumnsMeta
/**
* Returns metadata for all columns in a result set.
* @return array
*/
public function getColumnsMeta()
{
$count = mssql_num_fields($this->resultSet);
$res = array();
for ($i = 0; $i < $count; $i++) {
$row = (array) mssql_fetch_field($this->resultSet, $i);
$res[] = array('name' => $row['name'], 'fullname' => $row['column_source'] ? $row['column_source'] . '.' . $row['name'] : $row['name'], 'table' => $row['column_source'], 'nativetype' => $row['type']);
}
return $res;
}
示例7: fieldInfo
/**
* mysql_fetch_field() wrapper
* Returns false if the field doesn't exist
*
* @param $table
* @param $field
*/
function fieldInfo($table, $field)
{
$table = $this->tableName($table);
$res = $this->query("SELECT TOP 1 * FROM {$table}");
$n = mssql_num_fields($res->result);
for ($i = 0; $i < $n; $i++) {
$meta = mssql_fetch_field($res->result, $i);
if ($field == $meta->name) {
return new MSSQLField($meta);
}
}
return false;
}
示例8: mssql_to_table
function mssql_to_table($sql)
{
$fields_array = array();
$num_fields = 0;
$num_row = 0;
// find position of "FROM" in query
$fpos = strpos($sql, 'from');
// get string starting from the first word after "FROM"
$strfrom = substr($sql, $fpos + 5, 50);
// Find position of the first space after the first word in the string
$Opos = strpos($strfrom, ' ');
//Get table name. If query pull data from more then one table only first table name will be read.
$table = substr($strfrom, 0, $Opos);
// Get result from query
$result = mssql_query($sql) or die('Invalid query: ' . mssql_error());
$num_row = mssql_numrows($result);
print '<html>';
print '<head><title>';
print 'View ' . $table . '</title>';
print '<link rel="stylesheet" href="style.css">';
print "</head>";
print '<body><br>';
if ($num_row > 0) {
//Get number of fields in query
$num_fields = mssql_num_fields($result);
# get column metadata
$i = 0;
//Set table width 15% for each column
$width = 15 * $num_fields;
print '<br><table width=' . $width . '% align="center"><tr>';
print '<tr><th colspan=' . $num_fields . '>View ' . $table . '</th></tr>';
while ($i < $num_fields) {
//Get fields (columns) names
$meta = mssql_fetch_field($result);
$fields_array[] = $meta->name;
//Display column headers in upper case
print '<th><b>' . strtoupper($fields_array[$i]) . '</b></th>';
$i = $i + 1;
}
print '</tr>';
//Get values for each row and column
while ($row = mssql_fetch_row($result)) {
print '<tr>';
for ($i = 0; $i < $num_fields; $i++) {
//Display values for each row and column
print '<td>' . $row[$i] . '</td>';
}
print '</tr>';
}
}
return;
}
示例9: fetch_field
/**
* Get column information
* @param int
* @return object
*/
protected function fetch_field($intOffset)
{
return @mssql_fetch_field($this->resResult, $intOffset);
}
示例10: FetchField
function FetchField($fieldOffset = -1)
{
if ($fieldOffset != -1) {
$f = @mssql_fetch_field($this->_queryID, $fieldOffset);
} else {
if ($fieldOffset == -1) {
/* The $fieldOffset argument is not provided thus its -1 */
$f = @mssql_fetch_field($this->_queryID);
}
}
$false = false;
if (empty($f)) {
return $false;
}
return $f;
}
示例11: metadata
function metadata($table)
{
$count = 0;
$id = 0;
$res = array();
$this->connect();
$id = mssql_query("select * from {$table}", $this->Link_ID);
if (!$id) {
$this->halt('Metadata query failed.');
}
$count = mssql_num_fields($id);
for ($i = 0; $i < $count; $i++) {
$info = mssql_fetch_field($id, $i);
$res[$info->name] = $info;
/*
$res[$i]['table'] = $table;
$res[$i]['name'] = $info->name;
$res[$i]['len'] = $info->max_length;
$res[$i]['flags'] = $info->numeric;
$res[$i]['type'] = $info->type;
*/
}
$this->free_result();
return $res;
}
示例12: GetColumnNames
function GetColumnNames($result, &$column_names)
{
$result_value = intval($result);
if (!isset($this->highest_fetched_row[$result_value])) {
return $this->SetError("Get column names", "it was specified an inexisting result set");
}
if (!isset($this->columns[$result_value])) {
$this->columns[$result_value] = array();
for ($column = 0; @mssql_field_seek($result, $column); $column++) {
$field = mssql_fetch_field($result);
$this->columns[$result_value][strtolower($field->name)] = $column;
}
}
$column_names = $this->columns[$result_value];
return 1;
}
示例13: getFieldsArray
/**
* @see DBManager::getFieldsArray()
*/
public function getFieldsArray($result, $make_lower_case = false)
{
$field_array = array();
if (!isset($result) || empty($result)) {
return 0;
}
$i = 0;
while ($i < mssql_num_fields($result)) {
$meta = mssql_fetch_field($result, $i);
if (!$meta) {
return 0;
}
if ($make_lower_case == true) {
$meta->name = strtolower($meta->name);
}
$field_array[] = $meta->name;
$i++;
}
return $field_array;
}
示例14: columnData
public function columnData()
{
if (empty($this->query)) {
return false;
}
$columns = array();
for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) {
$field = mssql_fetch_field($this->query, $i);
$columns[$i] = new stdClass();
$columns[$i]->name = $field->name;
$columns[$i]->type = $field->type;
$columns[$i]->maxLength = $field->max_length;
$columns[$i]->primaryKey = false;
}
return $columns;
}
示例15: fetch_fields
function fetch_fields($query)
{
return mssql_fetch_field($query);
}