fixed failing tests

This commit is contained in:
yitam 2017-05-02 15:39:45 -07:00
parent de4033f3ca
commit fc029b27d7
6 changed files with 73 additions and 59 deletions

View file

@ -1,10 +1,10 @@
<?php
include_once 'autonomous_setup.php';
$conn1 = new PDO("sqlsrv:Server=$serverName", $username, $password);
include 'MsSetup.inc';
$conn1 = new PDO("sqlsrv:Server=$server", $uid, $pwd);
$connId1 = ConnectionID($conn1);
$conn1 = null;
$conn2 = new PDO("sqlsrv:Server=$serverName", $username, $password);
$conn2 = new PDO("sqlsrv:Server=$server", $uid, $pwd);
$connId2 = ConnectionID($conn2);
if ($connId1 === $connId2){
@ -15,11 +15,11 @@ if ($connId1 === $connId2){
function ConnectionID($conn)
{
$tsql = "SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID";
$stmt = $conn->query($tsql);
$connID = $stmt->fetchColumn(0);
$stmt->closeCursor();
$stmt = null;
return ($connID);
$tsql = "SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID";
$stmt = $conn->query($tsql);
$connID = $stmt->fetchColumn(0);
$stmt->closeCursor();
$stmt = null;
return ($connID);
}
?>

View file

@ -4,7 +4,7 @@ Test PDO::setAttribute() and PDO::getAttribute() methods.
<?php require('skipif.inc'); ?>
--FILE--
<?php
require_once("MsSetup.inc");
include("MsSetup.inc");
// A custom PDO statement class to test PDO::ATTR_STATEMENT_CLASS
class CustomPDOStatement extends PDOStatement

View file

@ -28,12 +28,12 @@ def executeSQLscriptUnix(sqlfile, conn_options, dbname):
# This is a workaround because sqlcmd in Unix does not support -v option for variables.
# It inserts setvar dbname into the beginning of a temp .sql file
tmpFileName = sqlfile[0:-4] + '_tmp.sql'
redirect_string = '(echo :setvar dbname {0}) > {2}; cat {1} >> {2}; cat {2}; '
# redirect_string = '(echo :setvar dbname {0}) > {2}; cat {1} >> {2}; cat {2}; '
redirect_string = '(echo :setvar dbname {0}) > {2}; cat {1} >> {2}; '
sqlcmd = 'sqlcmd ' + conn_options + ' -i ' + tmpFileName
print ('display contents of tmpFileName')
show_cmd = 'sqlcmd ' + conn_options + ' -Q \"select @@Version\" '
executeCommmand(show_cmd)
# show_cmd = 'sqlcmd ' + conn_options + ' -Q \"select @@Version\" '
# executeCommmand(show_cmd)
inst_command = redirect_string.format(dbname, sqlfile, tmpFileName) + sqlcmd
executeCommmand(inst_command)

View file

@ -1,10 +1,10 @@
<?php
include_once 'autonomous_setup.php';
$conn1 = sqlsrv_connect( $serverName, $connectionInfo);
include 'MsCommon.inc';
$conn1 = Connect();
$connId1 = ConnectionID($conn1);
sqlsrv_close($conn1);
$conn2 = sqlsrv_connect( $serverName, $connectionInfo);
$conn2 = Connect();
$connId2 = ConnectionID($conn2);
if ($connId1 === $connId2){
@ -15,11 +15,11 @@ if ($connId1 === $connId2){
function ConnectionID($conn)
{
$tsql = "SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID";
$stmt = sqlsrv_query($conn, $tsql);
sqlsrv_fetch($stmt);
$connID = sqlsrv_get_field($stmt, 0);
sqlsrv_free_stmt($stmt);
return ($connID);
$tsql = "SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID";
$stmt = sqlsrv_query($conn, $tsql);
sqlsrv_fetch($stmt);
$connID = sqlsrv_get_field($stmt, 0);
sqlsrv_free_stmt($stmt);
return ($connID);
}
?>

View file

@ -35,10 +35,7 @@ $stmt = sqlsrv_prepare($conn, $query);
// Get field metadata
$metadata = sqlsrv_field_metadata($stmt);
foreach($metadata as $fieldMetadata)
$res[] = $fieldMetadata;
var_dump($res);
var_dump($metadata);
sqlsrv_free_stmt( $stmt);
sqlsrv_close($conn);

View file

@ -24,10 +24,7 @@ $stmt = sqlsrv_prepare($conn, $sql);
// Get and display field metadata
$metadata = sqlsrv_field_metadata($stmt);
foreach($metadata as $meta)
{
print_r($meta);
}
var_dump($metadata);
// Free statement and connection resources
sqlsrv_free_stmt($stmt);
@ -37,31 +34,51 @@ print "Done"
?>
--EXPECT--
Array
(
[Name] => पासपोर्ट
[Type] => 1
[Size] => 2
[Precision] =>
[Scale] =>
[Nullable] => 1
)
Array
(
[Name] => پاسپورٹ
[Type] => 12
[Size] => 2
[Precision] =>
[Scale] =>
[Nullable] => 1
)
Array
(
[Name] => Διαβατήριο
[Type] => 12
[Size] => 0
[Precision] =>
[Scale] =>
[Nullable] => 1
)
Done
array(3) {
[0]=>
array(6) {
["Name"]=>
string(24) "पासपोर्ट"
["Type"]=>
int(1)
["Size"]=>
int(2)
["Precision"]=>
NULL
["Scale"]=>
NULL
["Nullable"]=>
int(1)
}
[1]=>
array(6) {
["Name"]=>
string(14) "پاسپورٹ"
["Type"]=>
int(12)
["Size"]=>
int(2)
["Precision"]=>
NULL
["Scale"]=>
NULL
["Nullable"]=>
int(1)
}
[2]=>
array(6) {
["Name"]=>
string(20) "Διαβατήριο"
["Type"]=>
int(12)
["Size"]=>
int(0)
["Precision"]=>
NULL
["Scale"]=>
NULL
["Nullable"]=>
int(1)
}
}
Done