You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am not sure is this is a bug or the behavior is correct but when i execute below code the web server crashes. It provides me with Bad Gateway
The original script that i used was much bigger but when i execute this test script i got the same issue:
`<?php
$server = "localhost";
$connectionInfo = ["UID" => "localhost", "PWD" => "localhost", 'Database' => 'localhost'];
$conn = sqlsrv_connect($server, $connectionInfo);
$stmt = sqlsrv_query($conn, "IF EXISTS (SELECT * FROM [sys].[objects] WHERE (name LIKE 'tbl_Test%') AND type in (N'U'))
BEGIN
select 0
END", [], ['Scrollable' => SQLSRV_CURSOR_CLIENT_BUFFERED]);
Following scenario is expexted, when the table name like tbl_Test exists it would return the amount of tables that are found, hens sqlsrv_has_rows would be true and sqlsrv_num_rows would return the amount
When no tables are found sqlsrv_has_rows must be false, sqlsrv_num_rows would be zero.
Thanks to look into this
PS i am using following setup
IIS10, PHP7.1.2 and SQL Driver 4.1.7-preview on an SQL 2016 server
The text was updated successfully, but these errors were encountered:
Hello @jansor, we are able to reproduce the issue. Thank you for reporting to us.
The behavior that you expect when table name like 'tbl_Test%' exists is incorrect. For example, say you have three tables 'tbl_Test1', 'tbl_Test2' and 'tbl_Test3'. The query you have will return 0 due to the select 0. Thus sqlsrv_num_rows will return 1 and not 3 as you have expected. If you want to count the number of tables with name like 'tbl_Test%', you can try the following query: SELECT COUNT(*) from sys.objects where (name LIKE 'tbl_Test%') AND (type = 'U')
Yes you are correct, in my testing previous i had the select query from the if statement also inside the select 0 statement. Thanks for the confirmation its a bug, i was confused with the result set.
Hi, I am not sure is this is a bug or the behavior is correct but when i execute below code the web server crashes. It provides me with Bad Gateway
The original script that i used was much bigger but when i execute this test script i got the same issue:
`<?php
$server = "localhost";
$connectionInfo = ["UID" => "localhost", "PWD" => "localhost", 'Database' => 'localhost'];
$conn = sqlsrv_connect($server, $connectionInfo);
$stmt = sqlsrv_query($conn, "IF EXISTS (SELECT * FROM [sys].[objects] WHERE (name LIKE 'tbl_Test%') AND type in (N'U'))
BEGIN
select 0
END", [], ['Scrollable' => SQLSRV_CURSOR_CLIENT_BUFFERED]);
if ($stmt) {
$hasRows = sqlsrv_has_rows($stmt);
$numRows = sqlsrv_num_rows($stmt);
var_dump($hasRows, $numRows);
}
?>`
Following scenario is expexted, when the table name like tbl_Test exists it would return the amount of tables that are found, hens sqlsrv_has_rows would be true and sqlsrv_num_rows would return the amount
When no tables are found sqlsrv_has_rows must be false, sqlsrv_num_rows would be zero.
Thanks to look into this
PS i am using following setup
IIS10, PHP7.1.2 and SQL Driver 4.1.7-preview on an SQL 2016 server
The text was updated successfully, but these errors were encountered: