applied changes as per review comments
This commit is contained in:
parent
f76ec856ee
commit
616f70ded6
|
@ -84,7 +84,6 @@ class BindParamOption
|
|||
$this->sqlType = $sqlType;
|
||||
}
|
||||
/**
|
||||
* @param resource $conn : connection resource
|
||||
* @param mix $var : variable to bind to the SQL statement parameter
|
||||
* @return array needed to bind parameter in sqlsrv_prepare
|
||||
*/
|
||||
|
@ -94,14 +93,23 @@ class BindParamOption
|
|||
$direction = null;
|
||||
$phpType = null;
|
||||
$sqlType = null;
|
||||
if ($this->direction) {
|
||||
$direction = constant($this->direction);
|
||||
if ($this->direction) {
|
||||
if (in_array($this->direction, array(SQLSRV_PARAM_IN, SQLSRV_PARAM_OUT, SQLSRV_PARAM_INOUT))) {
|
||||
$direction = constant($this->direction);
|
||||
} else {
|
||||
echo "BindParamOption: invalid direction for parameter!\n";
|
||||
}
|
||||
}
|
||||
if ($this->phpType) {
|
||||
$phpType = constant($this->phpType);
|
||||
try {
|
||||
$phpType = constant($this->phpType);
|
||||
} catch (Exception $e) {
|
||||
// there's something wrong with the input php type
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
if ($this->sqlType) {
|
||||
// parse out the datatype name, size, precision, and/or scale from a SQLSRV_SQLTYPE_ constant
|
||||
// parse the datatype name, size, precision, and/or scale from a SQLSRV_SQLTYPE_ constant
|
||||
$size = null;
|
||||
$prec = null;
|
||||
$scal = null;
|
||||
|
@ -117,12 +125,17 @@ class BindParamOption
|
|||
}
|
||||
}
|
||||
// get the sqlType constant
|
||||
if ($prec && $scal) {
|
||||
$sqlType = call_user_func($type, $prec, $scal);
|
||||
} elseif ($size) {
|
||||
$sqlType = call_user_func($type, $size);
|
||||
} else {
|
||||
$sqlType = constant($type);
|
||||
try {
|
||||
if ($prec && $scal) {
|
||||
$sqlType = call_user_func($type, $prec, $scal);
|
||||
} elseif ($size) {
|
||||
$sqlType = call_user_func($type, $size);
|
||||
} else {
|
||||
$sqlType = constant($type);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// there's something wrong with the input SQL type
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
return array($var, $direction, $phpType, $sqlType);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Driver setup Test
|
||||
--DESCRIPTION--
|
||||
Verifies the logging facility by checking the ability to set
|
||||
and retrieve the values of <EFBFBD>LogSubsystem<EFBFBD> and "LogSeverity<74>
|
||||
and retrieve the values of "LogSubsystem" and "LogSeverity"
|
||||
parameters.
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
|
@ -12,7 +12,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function LoggingSetup()
|
||||
function loggingSetup()
|
||||
{
|
||||
$testName = "Driver Logging setup";
|
||||
startTest($testName);
|
||||
|
@ -35,22 +35,12 @@ function LoggingSetup()
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
LoggingSetup();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
sqlsrv_configure('WarningsReturnAsError', 0);
|
||||
repro();
|
||||
try {
|
||||
loggingSetup();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Client Info Test
|
||||
--DESCRIPTION--
|
||||
Verifies the functionality of "sqlsrv_client_info<EFBFBD>.
|
||||
Verifies the functionality of "sqlsrv_client_info".
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function ClientInfo()
|
||||
function clientInfo()
|
||||
{
|
||||
$testName = "Connection - Client Info";
|
||||
startTest($testName);
|
||||
|
@ -33,38 +33,29 @@ function ClientInfo()
|
|||
$driverName = 'DriverName';
|
||||
}
|
||||
|
||||
ShowInfo($clientinfo1, 'ExtensionVer');
|
||||
ShowInfo($clientinfo1, $driverName);
|
||||
ShowInfo($clientinfo1, 'DriverVer');
|
||||
ShowInfo($clientinfo1, 'DriverODBCVer');
|
||||
showInfo($clientinfo1, 'ExtensionVer');
|
||||
showInfo($clientinfo1, $driverName);
|
||||
showInfo($clientinfo1, 'DriverVer');
|
||||
showInfo($clientinfo1, 'DriverODBCVer');
|
||||
|
||||
sqlsrv_close($conn1);
|
||||
|
||||
endTest($testName);
|
||||
}
|
||||
|
||||
function ShowInfo($clientInfo, $infoTag)
|
||||
function showInfo($clientInfo, $infoTag)
|
||||
{
|
||||
$info = $clientInfo[$infoTag];
|
||||
trace("$infoTag\t= $info\n");
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
ClientInfo();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
try {
|
||||
clientInfo();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
repro();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test "Connection - Client Info" completed successfully.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Server Info Test
|
||||
--DESCRIPTION--
|
||||
Verifies the functionality of <EFBFBD>sqlsrv_server_info<EFBFBD>.
|
||||
Verifies the functionality of "sqlsrv_server_info".
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function ServerInfo()
|
||||
function serverInfo()
|
||||
{
|
||||
$testName = "Connection - Server Info";
|
||||
startTest($testName);
|
||||
|
@ -24,16 +24,16 @@ function ServerInfo()
|
|||
die("Unexpected size for server_info array: ".$count1);
|
||||
}
|
||||
|
||||
ShowInfo($serverinfo1, 'CurrentDatabase');
|
||||
ShowInfo($serverinfo1, 'SQLServerName');
|
||||
ShowInfo($serverinfo1, 'SQLServerVersion');
|
||||
showInfo($serverinfo1, 'CurrentDatabase');
|
||||
showInfo($serverinfo1, 'SQLServerName');
|
||||
showInfo($serverinfo1, 'SQLServerVersion');
|
||||
|
||||
sqlsrv_close($conn1);
|
||||
|
||||
endTest($testName);
|
||||
}
|
||||
|
||||
function ShowInfo($serverInfo, $infoTag)
|
||||
function showInfo($serverInfo, $infoTag)
|
||||
{
|
||||
$info = $serverInfo[$infoTag];
|
||||
if (traceMode()) {
|
||||
|
@ -45,21 +45,12 @@ function ShowInfo($serverInfo, $infoTag)
|
|||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
ServerInfo();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
try {
|
||||
serverInfo();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
repro();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test "Connection - Server Info" completed successfully.
|
||||
|
|
|
@ -11,7 +11,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function PrepareAndExecute($noPasses)
|
||||
function prepareAndExecute($noPasses)
|
||||
{
|
||||
$testName = "Statement - Prepare and Execute";
|
||||
startTest($testName);
|
||||
|
@ -48,7 +48,7 @@ function PrepareAndExecute($noPasses)
|
|||
|
||||
// Prepare once and execute several times
|
||||
trace("Prepare a SELECT query on $tableName ...");
|
||||
$stmt2 = PrepareQuery($conn1, "SELECT * FROM [$tableName]");
|
||||
$stmt2 = prepareQuery($conn1, "SELECT * FROM [$tableName]");
|
||||
$numFields2 = sqlsrv_num_fields($stmt2);
|
||||
trace(" $numFields2 fields expected.\n");
|
||||
if ($numFields2 != $numFields1) {
|
||||
|
@ -85,24 +85,15 @@ function PrepareAndExecute($noPasses)
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
if (! isWindows()) {
|
||||
setUTF8Data(true);
|
||||
}
|
||||
try {
|
||||
PrepareAndExecute(5);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
setUTF8Data(false);
|
||||
if (!isWindows()) {
|
||||
setUTF8Data(true);
|
||||
}
|
||||
|
||||
repro();
|
||||
try {
|
||||
prepareAndExecute(5);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
setUTF8Data(false);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Statement Cancel Test
|
||||
--DESCRIPTION--
|
||||
Verifies that <EFBFBD>sqlsrv_cancel<EFBFBD> discards any pending data in current result set
|
||||
Verifies that "sqlsrv_cancel" discards any pending data in current result set
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function Cancel()
|
||||
function cancel()
|
||||
{
|
||||
$testName = "Statement - Cancel";
|
||||
startTest($testName);
|
||||
|
@ -44,21 +44,12 @@ function Cancel()
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
Cancel();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
try {
|
||||
cancel();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
repro();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test "Statement - Cancel" completed successfully.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
--TEST--
|
||||
Query Timeout Test
|
||||
--DESCRIPTION--
|
||||
Verifies the functionality of QueryTimeout option for both <EFBFBD>sqlsrv_query<EFBFBD>
|
||||
and <EFBFBD>sqlsrv_prepare<EFBFBD>.
|
||||
Verifies the functionality of QueryTimeout option for both "sqlsrv_query"
|
||||
and "sqlsrv_prepare".
|
||||
Executes a batch query that is expected to time out because it includes
|
||||
a request to delay the server execution (via WAITFOR DELAY) for a duration
|
||||
longer than the query timeout.
|
||||
|
@ -14,7 +14,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function QueryTimeout()
|
||||
function queryTimeout()
|
||||
{
|
||||
$testName = "Statement - Query Timeout";
|
||||
startTest($testName);
|
||||
|
@ -58,21 +58,12 @@ function QueryTimeout()
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
QueryTimeout();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
try {
|
||||
queryTimeout();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
repro();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test "Statement - Query Timeout" completed successfully.
|
||||
|
|
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function InvalidQuery()
|
||||
function invalidQuery()
|
||||
{
|
||||
$testName = "Statement - Invalid Query";
|
||||
startTest($testName);
|
||||
|
@ -61,22 +61,12 @@ function InvalidQuery()
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
InvalidQuery();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
try {
|
||||
invalidQuery();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
repro();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test "Statement - Invalid Query" completed successfully.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Fetch Array Test
|
||||
--DESCRIPTION--
|
||||
Verifies data retrieval via <EFBFBD>sqlsrv_fetch_array<EFBFBD>,
|
||||
Verifies data retrieval via "sqlsrv_fetch_array",
|
||||
by checking all fetch type modes.
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
|
@ -11,10 +11,8 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function FetchRow($minFetchMode, $maxFetchMode)
|
||||
function fetchRow($minFetchMode, $maxFetchMode)
|
||||
{
|
||||
include 'MsSetup.inc';
|
||||
|
||||
$testName = "Fetch - Array";
|
||||
startTest($testName);
|
||||
|
||||
|
@ -24,11 +22,12 @@ function FetchRow($minFetchMode, $maxFetchMode)
|
|||
}
|
||||
|
||||
setup();
|
||||
if (! isWindows()) {
|
||||
if (!isWindows()) {
|
||||
$conn1 = connect(array( 'CharacterSet'=>'UTF-8' ));
|
||||
} else {
|
||||
$conn1 = connect();
|
||||
}
|
||||
$tableName = 'TC44Test';
|
||||
createTable($conn1, $tableName);
|
||||
|
||||
$noRows = 10;
|
||||
|
@ -50,19 +49,19 @@ function FetchRow($minFetchMode, $maxFetchMode)
|
|||
|
||||
switch ($k) {
|
||||
case 1: // fetch array - numeric mode
|
||||
FetchArray($stmt1, $stmt2, SQLSRV_FETCH_NUMERIC, $noRows, $numFields);
|
||||
fetchArray($stmt1, $stmt2, SQLSRV_FETCH_NUMERIC, $noRows, $numFields);
|
||||
break;
|
||||
|
||||
case 2: // fetch array - associative mode
|
||||
FetchArray($stmt1, $stmt2, SQLSRV_FETCH_ASSOC, $noRows, $numFields);
|
||||
fetchArray($stmt1, $stmt2, SQLSRV_FETCH_ASSOC, $noRows, $numFields);
|
||||
break;
|
||||
|
||||
case 3: // fetch array - both numeric & associative
|
||||
FetchArray($stmt1, $stmt2, SQLSRV_FETCH_BOTH, $noRows, $numFields);
|
||||
fetchArray($stmt1, $stmt2, SQLSRV_FETCH_BOTH, $noRows, $numFields);
|
||||
break;
|
||||
|
||||
default: // default
|
||||
FetchArray($stmt1, $stmt2, null, $noRows, $numFields);
|
||||
fetchArray($stmt1, $stmt2, null, $noRows, $numFields);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,7 @@ function FetchRow($minFetchMode, $maxFetchMode)
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
function FetchArray($stmt, $stmtRef, $mode, $rows, $fields)
|
||||
function fetchArray($stmt, $stmtRef, $mode, $rows, $fields)
|
||||
{
|
||||
$size = $fields;
|
||||
$fetchMode = $mode;
|
||||
|
@ -109,7 +108,7 @@ function FetchArray($stmt, $stmtRef, $mode, $rows, $fields)
|
|||
}
|
||||
$rowRref = sqlsrv_fetch($stmtRef);
|
||||
for ($j = 0; $j < $fields; $j++) {
|
||||
if (!CheckData($row, $stmtRef, $j, $fetchMode)) {
|
||||
if (!checkData($row, $stmtRef, $j, $fetchMode)) {
|
||||
setUTF8Data(false);
|
||||
die("Data corruption on row ".($i + 1)." column ".($j + 1));
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ function FetchArray($stmt, $stmtRef, $mode, $rows, $fields)
|
|||
}
|
||||
|
||||
|
||||
function CheckData($row, $stmt, $index, $mode)
|
||||
function checkData($row, $stmt, $index, $mode)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
|
@ -156,24 +155,15 @@ function CheckData($row, $stmt, $index, $mode)
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
if (! isWindows()) {
|
||||
setUTF8Data(true);
|
||||
}
|
||||
try {
|
||||
FetchRow(1, 4);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
setUTF8Data(false);
|
||||
if (!isWindows()) {
|
||||
setUTF8Data(true);
|
||||
}
|
||||
|
||||
repro();
|
||||
try {
|
||||
fetchRow(1, 4);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
setUTF8Data(false);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Fetch Object Test
|
||||
--DESCRIPTION--
|
||||
Verifies data retrieval via <EFBFBD>sqlsrv_fetch_object<EFBFBD>.
|
||||
Verifies data retrieval via "sqlsrv_fetch_object".
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -17,7 +17,7 @@ class TestClass
|
|||
}
|
||||
}
|
||||
|
||||
function FetchRow($minFetchMode, $maxFetchMode)
|
||||
function fetchRow($minFetchMode, $maxFetchMode)
|
||||
{
|
||||
include 'MsSetup.inc';
|
||||
|
||||
|
@ -51,17 +51,17 @@ function FetchRow($minFetchMode, $maxFetchMode)
|
|||
|
||||
switch ($k) {
|
||||
case 0: // fetch array (to retrieve reference values)
|
||||
$expected = FetchArray($stmt1, $noRowsInserted, $numFields);
|
||||
$expected = fetchArray($stmt1, $noRowsInserted, $numFields);
|
||||
break;
|
||||
|
||||
case 1: // fetch object (without class)
|
||||
$actual = FetchObject($stmt1, $noRowsInserted, $numFields, false);
|
||||
CheckData($noRowsInserted, $numFields, $actual, $expected);
|
||||
$actual = fetchObject($stmt1, $noRowsInserted, $numFields, false);
|
||||
checkData($noRowsInserted, $numFields, $actual, $expected);
|
||||
break;
|
||||
|
||||
case 2: // fetch object (with class)
|
||||
$actual = FetchObject($stmt1, $noRowsInserted, $numFields, true);
|
||||
CheckData($noRowsInserted, $numFields, $actual, $expected);
|
||||
$actual = fetchObject($stmt1, $noRowsInserted, $numFields, true);
|
||||
checkData($noRowsInserted, $numFields, $actual, $expected);
|
||||
break;
|
||||
|
||||
default: // default
|
||||
|
@ -78,7 +78,7 @@ function FetchRow($minFetchMode, $maxFetchMode)
|
|||
}
|
||||
|
||||
|
||||
function FetchObject($stmt, $rows, $fields, $useClass)
|
||||
function fetchObject($stmt, $rows, $fields, $useClass)
|
||||
{
|
||||
trace("\tRetrieving $rows objects with $fields fields each ...\n");
|
||||
$values = array();
|
||||
|
@ -97,7 +97,7 @@ function FetchObject($stmt, $rows, $fields, $useClass)
|
|||
}
|
||||
|
||||
|
||||
function FetchArray($stmt, $rows, $fields)
|
||||
function fetchArray($stmt, $rows, $fields)
|
||||
{
|
||||
$values = array();
|
||||
for ($i = 0; $i < $rows; $i++) {
|
||||
|
@ -111,12 +111,12 @@ function FetchArray($stmt, $rows, $fields)
|
|||
}
|
||||
|
||||
|
||||
function CheckData($rows, $fields, $actualValues, $expectedValues)
|
||||
function checkData($rows, $fields, $actualValues, $expectedValues)
|
||||
{
|
||||
if (($actualValues != null) && ($expectedValues != null)) {
|
||||
for ($i = 0; $i < $rows; $i++) {
|
||||
for ($j = 0; $j < $fields; $j++) {
|
||||
$colName = GetColName($j + 1);
|
||||
$colName = getColName($j + 1);
|
||||
$actual = $actualValues[$i]->$colName;
|
||||
$expected = $expectedValues[$i][$colName];
|
||||
if ($actual != $expected) {
|
||||
|
@ -127,22 +127,12 @@ function CheckData($rows, $fields, $actualValues, $expectedValues)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
try {
|
||||
FetchRow(0, 2);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
try {
|
||||
fetchRow(0, 2);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
repro();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Test "Fetch - Object" completed successfully.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Fetch Next Result Test
|
||||
--DESCRIPTION--
|
||||
Verifies the functionality of <EFBFBD>sqlsvr_next_result<EFBFBD>
|
||||
Verifies the functionality of "sqlsrv_next_result"
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function FetchFields()
|
||||
function fetchFields()
|
||||
{
|
||||
include 'MsSetup.inc';
|
||||
|
||||
|
@ -82,25 +82,16 @@ function FetchFields()
|
|||
endTest($testName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
if (! isWindows()) {
|
||||
setUTF8Data(true);
|
||||
}
|
||||
|
||||
try {
|
||||
FetchFields();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
setUTF8Data(false);
|
||||
if (!isWindows()) {
|
||||
setUTF8Data(true);
|
||||
}
|
||||
|
||||
repro();
|
||||
try {
|
||||
fetchFields();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
setUTF8Data(false);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function InsertNullsTest($phptype, $sqltype)
|
||||
function insertNullsTest($phptype, $sqltype)
|
||||
{
|
||||
$outvar = null;
|
||||
|
||||
|
@ -25,12 +25,7 @@ function InsertNullsTest($phptype, $sqltype)
|
|||
|
||||
createTable($conn, $tableName);
|
||||
|
||||
$stmt = sqlsrv_query(
|
||||
$conn,
|
||||
<<<SQL
|
||||
SELECT [TABLE_NAME],[COLUMN_NAME],[IS_NULLABLE] FROM [INFORMATION_SCHEMA].[COLUMNS] WHERE [TABLE_NAME] = '$tableName'
|
||||
SQL
|
||||
);
|
||||
$stmt = sqlsrv_query($conn, "SELECT [TABLE_NAME],[COLUMN_NAME],[IS_NULLABLE] FROM [INFORMATION_SCHEMA].[COLUMNS] WHERE [TABLE_NAME] = '$tableName'");
|
||||
|
||||
if ($stmt === false) {
|
||||
fatalError("Could not query for column information on table $tableName");
|
||||
|
@ -44,11 +39,7 @@ SQL
|
|||
trace($columnName . ": " . $nullable . "\n");
|
||||
|
||||
if (($nullable == 'YES') && (strpos($columnName, "binary") !== false)) {
|
||||
$stmt2 = sqlsrv_prepare(
|
||||
$conn,
|
||||
"INSERT INTO [$tableName] ([" . $columnName . "]) VALUES (?)",
|
||||
array(array( null, SQLSRV_PARAM_IN, $phptype, $sqltype))
|
||||
);
|
||||
$stmt2 = sqlsrv_prepare($conn, "INSERT INTO [$tableName] ([" . $columnName . "]) VALUES (?)", array(array( null, SQLSRV_PARAM_IN, $phptype, $sqltype)));
|
||||
|
||||
if (!sqlsrv_execute($stmt2)) {
|
||||
print_r(sqlsrv_errors(SQLSRV_ERR_ALL));
|
||||
|
@ -57,41 +48,29 @@ SQL
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
|
||||
return $failed;
|
||||
}
|
||||
|
||||
$failed = null;
|
||||
|
||||
$testName = "PHP - Insert Nulls";
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
$failed = null;
|
||||
startTest($testName);
|
||||
|
||||
$testName = "PHP - Insert Nulls";
|
||||
|
||||
startTest($testName);
|
||||
|
||||
try {
|
||||
$failed |= InsertNullsTest(SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY), null);
|
||||
$failed |= InsertNullsTest(null, SQLSRV_SQLTYPE_VARBINARY('10'));
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
fatalError("Possible Regression: Could not insert NULL");
|
||||
}
|
||||
|
||||
endTest($testName);
|
||||
try {
|
||||
$failed |= insertNullsTest(SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY), null);
|
||||
$failed |= insertNullsTest(null, SQLSRV_SQLTYPE_VARBINARY('10'));
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
repro();
|
||||
if ($failed) {
|
||||
fatalError("Possible Regression: Could not insert NULL");
|
||||
}
|
||||
|
||||
endTest($testName);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
|
|
@ -9,7 +9,7 @@ Fix for 168256.
|
|||
|
||||
require_once('MsCommon.inc');
|
||||
$connectionInfo = array( "Database"=>"test");
|
||||
if (!($conn = Connect())) {
|
||||
if (!($conn = connect())) {
|
||||
fatalError("Could not connect");
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Fix for 168256.
|
|||
sqlsrv_configure('LogSeverity', SQLSRV_LOG_SEVERITY_ALL);
|
||||
|
||||
require_once('MsCommon.inc');
|
||||
if (!($conn = Connect())) {
|
||||
if (!($conn = connect())) {
|
||||
fatalError("Could not connect");
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ fix for 182741.
|
|||
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
$conn = Connect();
|
||||
$conn = connect();
|
||||
|
||||
if (!$conn) {
|
||||
fatalError("Could not connect");
|
||||
|
|
|
@ -25,7 +25,7 @@ $stmt = sqlsrv_query($conn, $sql);
|
|||
// Read data from the table
|
||||
$sql = "SELECT * FROM $tableName";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
for ($i=0; $i<3; $i++) {
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC);
|
||||
var_dump($row[0]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue