Sqlsrv查询不显示任何结果

时间:2016-02-19 09:43:18

标签: php sql-server sqlsrv

SELECT * FROM dbo.Warehouse会返回结果,但是当我更改为SELECT * FROM dbo.Accessories时,它既不会显示任何结果,也不会显示回显'未找到行'。 Warehouse和Accessories表都有行。这是我的剧本。

<?php

require('db_connect.php');
$query = 'SELECT * FROM dbo.Warehouse';
$params = array();
$options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query($conn, $query, $params, $options);

if(!$stmt){
     die(print_r(sqlsrv_errors(),true));
}

$c = 0;
$result[] = array();
if(sqlsrv_num_rows($stmt) != 0){
    while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)){
        $row = array($c => $row);
        $result[$c] = $row;
        $c++;
    }
} else {
   echo("Rows not found");
}

echo json_encode($result);
?>

请提前帮助我,谢谢。 :(

0 个答案:

没有答案