<i id='Fnt9T'><tr id='Fnt9T'><dt id='Fnt9T'><q id='Fnt9T'><span id='Fnt9T'><b id='Fnt9T'><form id='Fnt9T'><ins id='Fnt9T'></ins><ul id='Fnt9T'></ul><sub id='Fnt9T'></sub></form><legend id='Fnt9T'></legend><bdo id='Fnt9T'><pre id='Fnt9T'><center id='Fnt9T'></center></pre></bdo></b><th id='Fnt9T'></th></span></q></dt></tr></i><div id='Fnt9T'><tfoot id='Fnt9T'></tfoot><dl id='Fnt9T'><fieldset id='Fnt9T'></fieldset></dl></div>
      • <bdo id='Fnt9T'></bdo><ul id='Fnt9T'></ul>

      <legend id='Fnt9T'><style id='Fnt9T'><dir id='Fnt9T'><q id='Fnt9T'></q></dir></style></legend>

      <small id='Fnt9T'></small><noframes id='Fnt9T'>

    1. <tfoot id='Fnt9T'></tfoot>

      1. mysqli 中 mysql_field_name 的替代方案

        时间:2023-09-24

              <tbody id='9eNio'></tbody>

                <bdo id='9eNio'></bdo><ul id='9eNio'></ul>

                • <tfoot id='9eNio'></tfoot>

                  <small id='9eNio'></small><noframes id='9eNio'>

                  <legend id='9eNio'><style id='9eNio'><dir id='9eNio'><q id='9eNio'></q></dir></style></legend>
                  <i id='9eNio'><tr id='9eNio'><dt id='9eNio'><q id='9eNio'><span id='9eNio'><b id='9eNio'><form id='9eNio'><ins id='9eNio'></ins><ul id='9eNio'></ul><sub id='9eNio'></sub></form><legend id='9eNio'></legend><bdo id='9eNio'><pre id='9eNio'><center id='9eNio'></center></pre></bdo></b><th id='9eNio'></th></span></q></dt></tr></i><div id='9eNio'><tfoot id='9eNio'></tfoot><dl id='9eNio'><fieldset id='9eNio'></fieldset></dl></div>
                • 本文介绍了mysqli 中 mysql_field_name 的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  所以我发现了这个将mysql查询转换为XML页面的很棒的函数,它看起来正是我需要的.唯一的问题是它使用了 mysql,但不再受支持,而且结果使用的函数之一不在 mysqli 中.有谁知道 mysql_field_name 的替代方法?

                  So I found this great function that converts mysql queries into a XML page, and it looks like exactly what I need. The only problem is that it uses mysql, but thats not supported anymore, and it turns out one of the functions used isn't in mysqli. Does anyone know of an alternative to mysql_field_name?

                  这是我找到的函数

                  function sqlToXml($queryResult, $rootElementName, $childElementName)
                  { 
                  $xmlData = "<?xml version="1.0" encoding="ISO-8859-1" ?>
                  "; 
                  $xmlData .= "<" . $rootElementName . ">";
                  
                  while($record = mysql_fetch_object($queryResult))
                  { 
                      /* Create the first child element */
                      $xmlData .= "<" . $childElementName . ">";
                  
                      for ($i = 0; $i < mysql_num_fields($queryResult); $i++)
                      { 
                          $fieldName = mysql_field_name($queryResult, $i); 
                  
                          /* The child will take the name of the table column */
                          $xmlData .= "<" . $fieldName . ">";
                  
                          /* We set empty columns with NULL, or you could set 
                              it to '0' or a blank. */
                          if(!empty($record->$fieldName))
                              $xmlData .= $record->$fieldName; 
                          else
                              $xmlData .= "null"; 
                  
                          $xmlData .= "</" . $fieldName . ">"; 
                      } 
                      $xmlData .= "</" . $childElementName . ">"; 
                  } 
                  $xmlData .= "</" . $rootElementName . ">"; 
                  
                  return $xmlData; 
                  }
                  

                  有问题的部分是

                  $fieldName = mysql_field_name($queryResult, $i);
                  

                  谢谢

                  迈克

                  推荐答案

                  有很多方法可以做到,我猜最相似的是:

                  There are many ways to do it, I guess the most similar would be:

                  $fieldName = mysqli_fetch_field_direct($result, $i)->name;
                  

                  http://www.php.net/手册/en/mysqli-result.fetch-field-direct.php

                  这篇关于mysqli 中 mysql_field_name 的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:CREATE TABLE IF NOT EXISTS 失败,表已经存在 下一篇:mysqli_poll 如何工作?

                  相关文章

                  最新文章

                  <i id='xqGJD'><tr id='xqGJD'><dt id='xqGJD'><q id='xqGJD'><span id='xqGJD'><b id='xqGJD'><form id='xqGJD'><ins id='xqGJD'></ins><ul id='xqGJD'></ul><sub id='xqGJD'></sub></form><legend id='xqGJD'></legend><bdo id='xqGJD'><pre id='xqGJD'><center id='xqGJD'></center></pre></bdo></b><th id='xqGJD'></th></span></q></dt></tr></i><div id='xqGJD'><tfoot id='xqGJD'></tfoot><dl id='xqGJD'><fieldset id='xqGJD'></fieldset></dl></div>

                  <tfoot id='xqGJD'></tfoot>
                    <bdo id='xqGJD'></bdo><ul id='xqGJD'></ul>

                  <legend id='xqGJD'><style id='xqGJD'><dir id='xqGJD'><q id='xqGJD'></q></dir></style></legend>

                    <small id='xqGJD'></small><noframes id='xqGJD'>