Reputation: 1667
Converting my code from mysql to SQL server (SQLsrv), but having issue founding the equlent to mysql_field_name as used here:
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']));
}
}
Upvotes: 0
Views: 822
Reputation: 77866
I think it would be sqlsrv_get_field()
. See below MSDN document (link) for documentation and code samples:
Syntax:
sqlsrv_get_field( resource $stmt, int $fieldIndex)
Taken from MSDN (A sample usage):
$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: ";
Upvotes: 1