作者:胡龙云积极_622 | 来源:互联网 | 2023-07-24 15:25
SoIfoundthisgreatfunctionthatconvertsmysqlqueriesintoaXMLpage,anditlookslikeexactl
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?
我找到了一个很棒的函数,它可以将mysql查询转换成XML页面,看起来和我需要的一模一样。唯一的问题是它使用的是mysql,但是它不再被支持了,而且它所使用的一个函数并不是在mysqli中。有人知道mysql_field_name的替代方法吗?
Here's the function that I found
这是我找到的函数
function sqlToXml($queryResult, $rootElementName, $childElementName)
{
$xmlData = "\n";
$xmlData .= "<" . $rootElementName . ">";
while($record = mysql_fetch_object($queryResult))
{
/* Create the first child element */
$xmlData .= "<" . $childElementName . ">";
for ($i = 0; $i ";
/* 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;
}
With the part in question is
有问题的部分是
$fieldName = mysql_field_name($queryResult, $i);
Thanks
谢谢
Mike
迈克
1 个解决方案