我有以下 SELECT 语句在 SQL Server 查询工具上“工作”并返回行。但是,当我在 PHP 上运行它时,它不会返回任何行。我知道连接和设置的工作方式与创建简单查询(例如“SELECT * from ...”)时一样有效。这是我的代码。
$tsql = "SELECT [d].[Device_Type_Name],
[a].[Company_ID] AS [Alliance],
[a].[Device_Address]
FROM [dbo].[AL_LKP_User_Device] AS [a]
INNER JOIN [dbo].[AL_LKP_User] AS [b]
ON [a].[Login_ID] = [b].[Login_ID]
INNER JOIN [dbo].[AL_LKP_NOTIFICATION_MASTER_LOG] AS [c]
ON [b].[Login_ID] = [c].[Login_ID]
INNER JOIN [dbo].[AL_LKP_Device_Type] AS [d]
ON [a].[Device_Type_ID] = [d].[Device_Type_ID]";
$stmt = sqlsrv_query( $conn, $tsql);
if( !$stmt )
{
die( print_r( sqlsrv_errors(), true));
}
$rows = sqlsrv_has_rows($stmt);
if ($rows === true)
echo "There are rows. <br />";
else
echo "There are no rows. <br />";
当那里实际上有行时,我不断得到没有行。我需要在 SQL 语句中更改什么?