• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysqli_fetch_field函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mysqli_fetch_field函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_fetch_field函数的具体用法?PHP mysqli_fetch_field怎么用?PHP mysqli_fetch_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mysqli_fetch_field函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: algorithm

 public function algorithm(array $dataPack)
 {
     $this->tableMaster = IStrategy::TABLENOW;
     $this->hookup = UniversalConnect::doConnect();
     //Create Query Statement
     $sql = "SELECT * FROM {$this->tableMaster}";
     //Conditional statement in MySQL command
     if ($result = $this->hookup->query($sql)) {
         printf("Select returned %d rows.<p />", $result->num_rows);
         echo "<link rel='stylesheet' href='main.css'>";
         echo "<table>";
         while ($finfo = mysqli_fetch_field($result)) {
             echo "<th>&nbsp;{$finfo->name}</th>";
         }
         echo "</tr>\n";
         while ($row = mysqli_fetch_row($result)) {
             echo "<tr >";
             foreach ($row as $cell) {
                 echo "<td >{$cell}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
         $result->close();
     }
     $this->hookup->close();
 }
开发者ID:emilianocarvalho,项目名称:BlockTmkt,代码行数:27,代码来源:DisplayAll.php


示例2: fn_execSQL

function fn_execSQL($sql, $r = 0)
{
    global $conexao;
    if (mysqli_multi_query($conexao, $sql)) {
        $resultado = mysqli_store_result($conexao);
        if ($resultado) {
            //prepara um array com os campos/colunas da consulta
            $i = 0;
            while ($obj = mysqli_fetch_field($resultado)) {
                $arrayCampos[$i] = $obj->name;
                $i++;
            }
            //prepara um array associativo com o resultado da consulta
            $i = 0;
            while ($linha = mysqli_fetch_array($resultado)) {
                for ($j = 0; $j < count($arrayCampos); $j++) {
                    $retorno[$i][$arrayCampos[$j]] = $linha[$arrayCampos[$j]];
                }
                $i++;
            }
            mysqli_free_result($resultado);
        }
        //mysqli_close($conexao_geral);
        if (isset($retorno)) {
            return $retorno;
        } else {
            return null;
        }
    } else {
        echo "<p>N�o foi poss�vel executar a seguinte instru��o SQL:</p><p><strong>{$sql}</strong></p>\n" . "<p>Erro MySQL: " . mysqli_error($conexao) . "</p>";
        exit;
        //mysqli_close($conexao_geral);
    }
}
开发者ID:iaraujoisraell,项目名称:Educacional,代码行数:34,代码来源:conexao.php


示例3: __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;
             $numFields = mysqli_num_fields($this->result);
             while ($i < $numFields) {
                 //				   $meta = mysqli_fetch_field($this->result, $i);
                 $meta = mysqli_fetch_field($this->result);
                 if ($meta) {
                     //						$this->_columns->add(new anvilData_mysqli_Column($meta->name, $meta->type));
                     $firePHP->_log($meta);
                     $newColumn = new anvilData_mysqli_Column($meta->name, $meta->type);
                     $this->_columns->add($newColumn);
                 }
                 $i++;
             }
         }
         return $this->_columns;
     } else {
         return parent::__get($propertyName);
     }
 }
开发者ID:nslevkoff,项目名称:phpAnvil2,代码行数:34,代码来源:anvilData_mysqli_Recordset.class.php


示例4: query

 public function query($sql)
 {
     $pos = stripos($sql, 'select');
     if (is_numeric($pos)) {
         //是select 语句
         $rs = mysqli_query($this->conn, $sql);
         if (mysqli_errno($this->conn)) {
             die('you have an error ' . mysqli_error($this->conn));
         }
         if ($rs === false) {
             return mysqli_affected_rows($this->conn);
         }
         //什么时候返回是false呢...哦子查询是select
         $columns = array();
         while ($property = @mysqli_fetch_field($rs)) {
             $columns[] = $property->name;
         }
         $arr = array();
         while ($result = @mysqli_fetch_row($rs)) {
             $arr[] = array_combine($columns, $result);
         }
         return $arr;
     } else {
         mysqli_query($this->conn, $sql);
         if (mysqli_errno($this->conn)) {
             die('you have an error ' . mysqli_error($this->conn));
         }
         return mysqli_affected_rows($this->conn);
     }
 }
开发者ID:Qbuer,项目名称:pt-wechat,代码行数:30,代码来源:conn.class.php


示例5: query

 /** Custom SQL Query **/
 function query($query, $singleResult = 0)
 {
     $this->_result = mysqli_query($query, $this->_dbHandle);
     if (preg_match("/select/i", $query)) {
         $result = array();
         $table = array();
         $field = array();
         $tempResults = array();
         $numOfFields = mysqli_num_fields($this->_result);
         for ($i = 0; $i < $numOfFields; ++$i) {
             array_push($table, mysqli_fetch_field($this->_result, $i));
             array_push($field, mysqli_fetch_field($this->_result, $i));
         }
         while ($row = mysqli_fetch_row($this->_result)) {
             for ($i = 0; $i < $numOfFields; ++$i) {
                 $table[$i] = trim(ucfirst($table[$i]), "s");
                 $tempResults[$table[$i]][$field[$i]] = $row[$i];
             }
             if ($singleResult == 1) {
                 mysqli_free_result($this->_result);
                 return $tempResults;
             }
             array_push($result, $tempResults);
         }
         mysqli_free_result($this->_result);
         return $result;
     }
 }
开发者ID:WHTGo,项目名称:EXP-Training,代码行数:29,代码来源:SqlQuery.php


示例6: getValue

 public function getValue($sSQL)
 {
     $oQuery = mysqli_query($this->_connection, $sSQL);
     if ($oQuery) {
         return mysqli_fetch_field($oQuery);
     }
     return false;
 }
开发者ID:ghtmh,项目名称:haushaltsplan,代码行数:8,代码来源:database.class.php


示例7: list_fields

 /**
  * Fetch Field Names
  *
  * Generates an array of column names
  *
  * @access    public
  * @return    array
  */
 function list_fields()
 {
     $field_names = array();
     while ($field = mysqli_fetch_field($this->result_id)) {
         $field_names[] = $field->name;
     }
     return $field_names;
 }
开发者ID:jencko,项目名称:sz_codeigniter,代码行数:16,代码来源:mysqli_result.php


示例8: mysqliAdapter

 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * @param resource $d The datasource resource
  */
 function mysqliAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = mysqli_num_fields($d);
     $ob = "";
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (mysqli_num_rows($d) > 0) {
         mysqli_data_seek($d, 0);
         while ($line = mysqli_fetch_row($d)) {
             // write all of the array elements
             $ob .= "\n" . $fc;
             foreach ($line as $value) {
                 // write all of the array elements
                 if (is_string($value)) {
                     // type as string
                     $os = $this->_directCharsetHandler->transliterate($value);
                     //string flag, string length, and string
                     $len = strlen($os);
                     if ($len < 65536) {
                         $ob .= "" . pack('n', $len) . $os;
                     } else {
                         $ob .= "\f" . pack('N', $len) . $os;
                     }
                 } elseif (is_float($value) || is_int($value)) {
                     // type as double
                     $b = pack('d', $value);
                     // pack the bytes
                     if ($be) {
                         // if we are a big-endian processor
                         $r = strrev($b);
                     } else {
                         // add the bytes to the output
                         $r = $b;
                     }
                     $ob .= "" . $r;
                 } elseif (is_bool($value)) {
                     //type as bool
                     $ob .= "";
                     $ob .= pack('c', $value);
                 } elseif (is_null($value)) {
                     // null
                     $ob .= "";
                 }
             }
         }
     }
     $this->serializedData = $ob;
     // loop over all of the fields
     while ($field = mysqli_fetch_field($d)) {
         // decode each field name ready for encoding when it goes through serialization
         // and save each field name into the array
         $this->columnNames[] = $this->_directCharsetHandler->transliterate($field->name);
     }
     $this->numRows = mysqli_num_rows($d);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:62,代码来源:mysqliAdapter.php


示例9: get_fields

 public function get_fields($result_set)
 {
     $columnNames = array();
     $fieldMetadata = mysqli_fetch_field($result_set);
     foreach ($fieldMetadata as $value) {
         array_push($columnNames, $value);
         break;
     }
     return $columnNames;
 }
开发者ID:Akshayf444,项目名称:respi2,代码行数:10,代码来源:database.php


示例10: stmt_assoc

 private function stmt_assoc(&$stmt, array &$out)
 {
     $data = mysqli_stmt_result_metadata($stmt);
     $fields = array($this->_STMT);
     $out = array();
     while ($field = mysqli_fetch_field($data)) {
         $fields[] =& $out[$field->name];
     }
     call_user_func_array('mysqli_stmt_bind_result', $fields);
 }
开发者ID:habb0,项目名称:SulakeWeb,代码行数:10,代码来源:DataObject.MySQLi.php


示例11: GetFields

 function GetFields()
 {
     $_fields = array();
     $_result = mysqli_query($this->_Link, $this->SelectCommand);
     while ($_prop = mysqli_fetch_field($_result)) {
         $_field = array("Name" => $_prop->name, "Type" => $_prop->type, "Not_Null" => 0);
         array_push($_fields, $_field);
     }
     return $_fields;
 }
开发者ID:skydel,项目名称:universal-online-exam,代码行数:10,代码来源:MySQLiDataSource.php


示例12: SQL

function SQL($Query)
{
    global $DB;
    $args = func_get_args();
    if (count($args) == 1) {
        $result = $DB->query($Query);
        if ($result->num_rows) {
            $out = array();
            while (null != ($r = $result->fetch_array(MYSQLI_ASSOC))) {
                $out[] = $r;
            }
            return $out;
        }
        return null;
    } else {
        if (!($stmt = $DB->prepare($Query))) {
            trigger_error("Unable to prepare statement: {$Query}, reason: " . $DB->error . "");
        }
        array_shift($args);
        //remove $Query from args
        //the following three lines are the only way to copy an array values in PHP
        $a = array();
        foreach ($args as $k => &$v) {
            $a[$k] =& $v;
        }
        $types = str_repeat("s", count($args));
        //all params are strings, works well on MySQL and SQLite
        array_unshift($a, $types);
        call_user_func_array(array($stmt, 'bind_param'), $a);
        $stmt->execute();
        //fetching all results in a 2D array
        $metadata = $stmt->result_metadata();
        $out = array();
        $fields = array();
        if (!$metadata) {
            return null;
        }
        $length = 0;
        while (null != ($field = mysqli_fetch_field($metadata))) {
            $fields[] =& $out[$field->name];
            $length += $field->length;
        }
        call_user_func_array(array($stmt, "bind_result"), $fields);
        $output = array();
        $count = 0;
        while ($stmt->fetch()) {
            foreach ($out as $k => $v) {
                $output[$count][$k] = $v;
            }
            $count++;
        }
        $stmt->free_result();
        return $output;
    }
}
开发者ID:graficaSanCarlos,项目名称:imprenta,代码行数:55,代码来源:sqliHelper.php


示例13: db_getfieldslist

 /**
  * @param String stype
  * @return Number
  */
 public function db_getfieldslist($strSQL)
 {
     $res = array();
     $rs = mysqli_query($this->connectionObj->conn, $strSQL);
     while ($finfo = mysqli_fetch_field($rs)) {
         $stype = $this->getFieldTypeNumber($finfo->type, $finfo->flags);
         $res[] = array("fieldname" => $finfo->name, "type" => $stype, "not_null" => 0);
     }
     $rs->close();
     return $res;
 }
开发者ID:ryanblanchard,项目名称:Dashboard,代码行数:15,代码来源:MySQLiInfo.php


示例14: createQuery

function createQuery($table, $q, $starting, $add)
{
    global $mysqli;
    $getTableFields = $mysqli->query("SELECT * FROM " . $table);
    $query = $starting;
    while ($fields = mysqli_fetch_field($getTableFields)) {
        $query .= $fields->name . " LIKE '%" . $q . "%' OR ";
    }
    $query = substr($query, 0, -3);
    $query .= $add ? ")" : "";
    return $mysqli->query($query);
}
开发者ID:WISVCH,项目名称:facie-jetser,代码行数:12,代码来源:api.php


示例15: field_structures

 /**
  * Structure of our fields (type, length and null)
  *
  * @param resource $resource
  * @return array
  */
 public function field_structures($resource)
 {
     $result = [];
     if ($resource) {
         while ($finfo = mysqli_fetch_field($resource)) {
             $result[$finfo->name]['type'] = $this->field_type($finfo->type);
             $result[$finfo->name]['null'] = $finfo->flags & 1 ? false : true;
             $result[$finfo->name]['length'] = $finfo->length;
         }
     }
     return $result;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:18,代码来源:base.php


示例16: mysqliAdapter

 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * @param resource $d The datasource resource
  */
 function mysqliAdapter($d)
 {
     parent::RecordSetAdapter($d);
     while ($field = mysqli_fetch_field($d)) {
         $this->columns[] = $field->name;
     }
     if (mysqli_num_rows($d) > 0) {
         mysqli_data_seek($d, 0);
         while ($line = mysqli_fetch_row($d)) {
             $this->rows[] = $line;
         }
     }
 }
开发者ID:nimigeanu,项目名称:hollow,代码行数:19,代码来源:mysqliAdapter.php


示例17: stmt_bind_assoc

function stmt_bind_assoc(&$stmt, &$out)
{
    $data = mysqli_stmt_result_metadata($stmt);
    $fields = array();
    $out = array();
    $fields[0] = $stmt;
    $count = 1;
    while ($field = mysqli_fetch_field($data)) {
        $fields[$count] =& $out[$field->name];
        $count++;
    }
    call_user_func_array(mysqli_stmt_bind_result, $fields);
}
开发者ID:jonca44,项目名称:pdf-mailmerge,代码行数:13,代码来源:reactivate_account.php


示例18: db_getfieldslist

function db_getfieldslist($strSQL)
{
	global $conn;
	$res=array();
	$rs = mysqli_query($conn, $strSQL);
	while($finfo = mysqli_fetch_field($rs)) 
	{
		$stype=db_fieldtypenum($finfo->type,$finfo->flags);
		$res[]=array("fieldname"=>$finfo->name,"type"=>$stype,"not_null"=>0);
	}
	$rs->close();
	return $res;
}
开发者ID:helbertfurbino,项目名称:sgmofinanceiro,代码行数:13,代码来源:dbinfo.my.mysqli.php


示例19: query_output

 /**
  * @param $data - mysqli result
  * @param $title - true / false (show or not the title)
  * @return string
  */
 public function query_output($data)
 {
     if (!$data) {
         $table_output = 'No data to display, quitting.<br>';
         return 'error in htmloutput.php library class: query argument required';
     }
     //$table_output = 'Data was passed to query_output method.<br>';
     // $table_output = $table_output.'------------------------------------------------------------------------------------------------------------------------------------<br>';
     // display columns field names
     $i = 0;
     $table_output = '<html><body><table><tr>';
     while ($i < mysqli_num_fields($data)) {
         $meta = mysqli_fetch_field($data);
         if ($title == 'true') {
             $table_output = $table_output . '<td>' . $meta->name . '</td>';
         }
         $i = $i + 1;
     }
     $table_output = $table_output . '</tr>';
     // SHOULD Display only the selected range, thus making 'pages'.
     //$i     = $range['first_row'];
     //$count = $range['last_row'];
     // echo "from htmloutput.php: from ".$range['first_row']." to ".$range['last_row']." rows.<br>";
     //mysqli_data_seek($data, $range['first_row']);
     //if ($range['last_row'] !== -1 ) {
     //    $last_row = $range['last_row'];
     //} else {
     //    $last_row = mysqli_num_rows ($data);
     //}
     //$r = $range['first_row'];
     $r = 0;
     $last_row = mysqli_num_rows($data);
     while ($r < $last_row) {
         $row = mysqli_fetch_row($data);
         $table_output .= '<tr>';
         $count = count($row);
         $y = 0;
         //columns
         while ($y < $count) {
             $c_row = current($row);
             $table_output .= '<td>' . $c_row . '</td>';
             next($row);
             $y = $y + 1;
             // walk the columns one by one
         }
         $table_output .= '</tr>';
         $r = $r + 1;
     }
     echo '</table></body></html>';
     return $table_output;
 }
开发者ID:dagasaga,项目名称:css,代码行数:56,代码来源:htmloutput.php


示例20: field_data

 /**
  * Field data
  *
  * Generates an array of objects containing field meta-data
  *
  * @access	public
  * @return	array
  */
 function field_data()
 {
     $retval = array();
     while ($field = mysqli_fetch_field($this->result_id)) {
         $F = new stdClass();
         $F->name = $field->name;
         $F->type = $field->type;
         $F->default = $field->def;
         $F->max_length = $field->max_length;
         $F->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG ? 1 : 0;
         $retval[] = $F;
     }
     return $retval;
 }
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:22,代码来源:mysqli_result.php



注:本文中的mysqli_fetch_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysqli_fetch_field_direct函数代码示例发布时间:2022-05-15
下一篇:
PHP mysqli_fetch_assoc函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap