当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli_fetch_field函数代码示例

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


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


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