-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #285 from yitam/GH69
Fix and tests for issue #69
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/pdo_sqlsrv/pdo_069_fetch_empty_nvarchar_buffered.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--TEST-- | ||
GitHub issue #69 - fetching an empty nvarchar using client buffer | ||
--SKIPIF-- | ||
--FILE-- | ||
<?php | ||
// Connect | ||
require_once("autonomous_setup.php"); | ||
|
||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password); | ||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); | ||
|
||
$sql = "EXEC dbo.sp_executesql | ||
N'DECLARE @x nvarchar(max) | ||
SET @x = '''' -- empty string | ||
SELECT @x AS [Empty_Nvarchar_Max]'"; | ||
|
||
$stmt = $conn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED)); | ||
$stmt->execute(); | ||
|
||
$return = $stmt->fetchAll( PDO::FETCH_ASSOC ); | ||
print_r($return); | ||
|
||
// Free the statement and connection resources. | ||
$stmt = null; | ||
$conn = null; | ||
|
||
print "Done"; | ||
?> | ||
--EXPECT-- | ||
Array | ||
( | ||
[0] => Array | ||
( | ||
[Empty_Nvarchar_Max] => | ||
) | ||
|
||
) | ||
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--TEST-- | ||
GitHub issue #69 - fetching an empty nvarchar using client buffer | ||
--SKIPIF-- | ||
--FILE-- | ||
<?php | ||
function print_errors() | ||
{ | ||
die( print_r( sqlsrv_errors(), true)); | ||
} | ||
|
||
function test() | ||
{ | ||
require_once("autonomous_setup.php"); | ||
|
||
// Connect | ||
$conn = sqlsrv_connect($serverName, $connectionInfo); | ||
if( !$conn ) { print_errors(); } | ||
|
||
$sql = "EXEC dbo.sp_executesql | ||
N'DECLARE @x nvarchar(max) | ||
SET @x = '''' -- empty string | ||
SELECT @x AS [Empty_Nvarchar_Max]'"; | ||
|
||
$stmt = sqlsrv_query($conn, $sql, [], ["Scrollable" => 'buffered']); | ||
if (! $stmt) { print_errors(); } | ||
|
||
$return = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC); | ||
print_r($return); | ||
|
||
// Free the statement and connection resources. | ||
sqlsrv_free_stmt( $stmt); | ||
sqlsrv_close( $conn); | ||
} | ||
|
||
test(); | ||
|
||
print "Done"; | ||
?> | ||
--EXPECT-- | ||
Array | ||
( | ||
[Empty_Nvarchar_Max] => | ||
) | ||
Done |