gpt4 book ai didi

php - MYSQL_FIELD_NAME 相当于 SQL SERVER

转载 作者:行者123 更新时间:2023-11-29 13:02:34 25 4
gpt4 key购买 nike

将我的代码从 mysql 转换为 SQL Server (SQLsrv),但在创建与此处使用的 mysql_field_name 等价的内容时遇到问题:

foreach($this->aCols as $i=>$col)
{
if($col['c']=='')
{
if(is_string($col['f']))
$this->aCols[$i]['c']=ucfirst($col['f']);
else
$this->aCols[$i]['c']=ucfirst(mysql_field_name($res,$col['f']));
}
}

最佳答案

我认为应该是sqlsrv_get_field()。有关文档和代码示例,请参阅下面的 MSDN 文档(链接):

sqlsrv_get_field

语法:

sqlsrv_get_field( resource $stmt, int $fieldIndex)

取自 MSDN(示例用法):

$tsql = "SELECT ReviewerName, Comments 
FROM Production.ProductReview
WHERE ProductReviewID=1";
$stmt = sqlsrv_query( $conn, $tsql);

if( $stmt === false )
{
echo "Error in statement preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}

/* Make the first row of the result set available for reading. */
if( sqlsrv_fetch( $stmt ) === false )
{
echo "Error in retrieving row.\n";
die( print_r( sqlsrv_errors(), true));
}

$name = sqlsrv_get_field( $stmt, 0);
echo "$name: ";

关于php - MYSQL_FIELD_NAME 相当于 SQL SERVER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23136154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com