removed autonomous_setup.php
This commit is contained in:
parent
a5ee59bfa6
commit
e13b6e7528
1628
test/pdo_sqlsrv/MsCommon.inc
Normal file
1628
test/pdo_sqlsrv/MsCommon.inc
Normal file
File diff suppressed because one or more lines are too long
65
test/pdo_sqlsrv/MsData.inc
Normal file
65
test/pdo_sqlsrv/MsData.inc
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/*
|
||||
Microsoft SQL Server Driver for PHP - Unit Test Framework
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Description:
|
||||
Random data generator for INSERT statements.
|
||||
|
||||
*/
|
||||
|
||||
// globals
|
||||
|
||||
$table1 = "PDO_Types_1";
|
||||
$table2= "PDO_AllTypes";
|
||||
|
||||
$large_string = "This is a really large string used to test certain large data types like xml data type. The length of this string is greater than 256 to correctly test a large data type. This is currently used by atleast varchar type and by xml type. The fetch tests are the primary consumer of this string to validate that fetch on large types work fine. The length of this string as counted in terms of number of characters is 417.";
|
||||
|
||||
$string_col = array("'STRINGCOL1'", "'STRINGCOL2'");
|
||||
|
||||
$date_col = array("'2000-11-11 11:11:11.111'", "'2000-11-11 11:11:11.222'");
|
||||
|
||||
$large_string_col = array("' 1 " . $large_string . "'", "' 2 " . $large_string . "'");
|
||||
|
||||
$xml_col = array("'<xml> 1 " . $large_string . "</xml>'", "'<xml> 2 " . $large_string . "</xml>'");
|
||||
|
||||
$binary_col = array('0x0', '0x0');
|
||||
|
||||
$int_col = array ( 1, 2);
|
||||
|
||||
$decimal_col = array (111.111, 222.222);
|
||||
|
||||
$guid_col = array("'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'", "'BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB'");
|
||||
|
||||
$null_col = 'null';
|
||||
|
||||
$comma = ",";
|
||||
$closing_brace = "),";
|
||||
|
||||
class PDO_Types_1_Class{
|
||||
var $IntCol;
|
||||
var $CharCol;
|
||||
var $NCharCol;
|
||||
var $DateTimeCol;
|
||||
var $VarcharCol;
|
||||
var $NVarCharCol;
|
||||
var $FloatCol;
|
||||
var $XmlCol;
|
||||
|
||||
function dumpAll()
|
||||
{
|
||||
var_dump($this->IntCol);
|
||||
var_dump($this->CharCol);
|
||||
var_dump($this->NCharCol);
|
||||
var_dump($this->DateTimeCol);
|
||||
var_dump($this->VarcharCol);
|
||||
var_dump($this->NVarCharCol);
|
||||
var_dump($this->FloatCol);
|
||||
var_dump($this->XmlCol);
|
||||
}
|
||||
}
|
||||
$table1_class = 'PDO_Types_1_Class';
|
||||
|
||||
|
||||
|
||||
?>
|
38
test/pdo_sqlsrv/MsSetup.inc
Normal file
38
test/pdo_sqlsrv/MsSetup.inc
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/*
|
||||
Microsoft SQL Server Driver for PHP/PDO - Unit Test Framework
|
||||
Copyright (c) Microsoft Corporation. All rights reserved
|
||||
|
||||
Description:
|
||||
Global variables defining the execution context
|
||||
*/
|
||||
|
||||
if (isset($_ENV['MSSQL_SERVER']) || isset($_ENV['MSSQL_USER']) || isset($_ENV['MSSQL_PASSWORD'])) {
|
||||
$server = $_ENV['MSSQL_SERVER'];
|
||||
$uid = $_ENV['MSSQL_USER'];
|
||||
$pwd = $_ENV['MSSQL_PASSWORD'];
|
||||
$databaseName = $_ENV['MSSQL_DATABASE_NAME'];
|
||||
$DriverName = $_ENV['MSSQL_DRIVER_NAME'];
|
||||
} else {
|
||||
$server = 'SQL-2K12-SP3-1.galaxy.ad';
|
||||
$uid = 'sa';
|
||||
$pwd = 'Moonshine4me';
|
||||
$databaseName = 'test_win123';
|
||||
$DriverName = "ODBC Driver 11 for SQL Server";
|
||||
}
|
||||
|
||||
$driverType = true;
|
||||
$PhpDriver = "ODBC Driver 11 for SQL Server";
|
||||
|
||||
$tableName = 'pdo_test_table';
|
||||
$tableIndex = 'php_test_table_idx';
|
||||
$procName = 'php_test_proc';
|
||||
$fileName = 'php_test_file.dat';
|
||||
$dsn = "odbc:Driver={$DriverName};Server=$server";
|
||||
$connectionOptions = array();
|
||||
$daasMode = false;
|
||||
$marsMode = true;
|
||||
$dsnMode = true;
|
||||
$traceEnabled = false;
|
||||
|
||||
?>
|
|
@ -4,7 +4,7 @@ PDO Connection Pooling Test on Unix
|
|||
This test assumes odbcinst.ini has not been modified.
|
||||
This test also requires root privileges to modify odbcinst.ini file on Linux.
|
||||
--SKIPIF--
|
||||
<?php if(PHP_OS === "WINNT") die("Skipped: Test for Linux and Mac");
|
||||
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac");
|
||||
--FILE--
|
||||
<?php
|
||||
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
// Set SQL server + user + password
|
||||
$serverName = getenv('MSSQL_SERVERNAME') ?: "localhost";
|
||||
$username = getenv('MSSQL_USERNAME') ?: "sa";
|
||||
$password = getenv('MSSQL_PASSWORD') ?: "<YourStrong!Passw0rd>";
|
||||
|
||||
|
||||
// Generate unique DB name, example: php_20160817_1471475608267
|
||||
$dbName = "php_" . date("Ymd") . "_" . round(microtime(true)*1000);
|
||||
|
||||
// Generic table name example: php_20160817_1471475608267.dbo.php_firefly
|
||||
$tableName = $dbName.".dbo.php_firefly";
|
||||
|
||||
// Connection options
|
||||
$connectionInfo = array("UID"=>"$username", "PWD"=>"$password");
|
||||
?>
|
|
@ -1,14 +1,15 @@
|
|||
--TEST--
|
||||
Connection option APP name unicode
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$appName = "APP_PoP_银河";
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName;APP=$appName","$username","$password");
|
||||
$conn = new PDO("sqlsrv:server=$server;APP=$appName","$uid","$pwd");
|
||||
|
||||
// Query and Fetch
|
||||
$query = "SELECT APP_NAME()";
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
--TEST--
|
||||
Insert with quoted parameters
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", "$username", "$password" );
|
||||
$conn = new PDO( "sqlsrv:server=$server; database=$databaseName", "$uid", "$pwd" );
|
||||
|
||||
$param = 'a \' g';
|
||||
$param2 = $conn->quote( $param );
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Create table
|
||||
$query = "CREATE TABLE ".$tableName." (col1 VARCHAR(10), col2 VARCHAR(20))";
|
||||
$stmt = $conn->query($query);
|
||||
// Create a temporary table
|
||||
$tableName = '#tmpTable';
|
||||
$query = "CREATE TABLE $tableName (col1 VARCHAR(10), col2 VARCHAR(20))";
|
||||
$stmt = $conn->exec($query);
|
||||
if( $stmt === false ) { die(); }
|
||||
|
||||
// Inserd data
|
||||
|
@ -42,9 +40,6 @@ $query = "delete from $tableName where col1 = ?";
|
|||
$stmt = $conn->prepare( $query );
|
||||
$stmt->execute(array($param));
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
//free the statement and connection
|
||||
$stmt=null;
|
||||
$conn=null;
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
--TEST--
|
||||
uses an input/output parameter
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$dbh = new PDO( "sqlsrv:server=$serverName", "$username", "$password" );
|
||||
|
||||
// CREATE database
|
||||
$dbh->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$dbh = new PDO( "sqlsrv:server=$server; database=$databaseName", "$uid", "$pwd" );
|
||||
|
||||
$dbh->query("IF OBJECT_ID('dbo.sp_ReverseString', 'P') IS NOT NULL DROP PROCEDURE dbo.sp_ReverseString");
|
||||
$dbh->query("CREATE PROCEDURE dbo.sp_ReverseString @String as VARCHAR(2048) OUTPUT as SELECT @String = REVERSE(@String)");
|
||||
|
@ -19,9 +16,6 @@ $stmt->bindParam(1, $string, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT, 2048);
|
|||
$stmt->execute();
|
||||
print "Result: ".$string."\n"; // Expect 987654321
|
||||
|
||||
// DROP database
|
||||
$dbh->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
//free the statement and connection
|
||||
$stmt = null;
|
||||
$dbh = null;
|
||||
|
|
|
@ -1,49 +1,45 @@
|
|||
--TEST--
|
||||
Number of rows in a result set
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", "$username", "$password" );
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO( "sqlsrv:server=$server; database=$databaseName", "$uid", "$pwd" );
|
||||
|
||||
// Create table
|
||||
$stmt = $conn->query("CREATE TABLE ".$tableName." (c1 VARCHAR(32))");
|
||||
$tableName = '#tmpTable1';
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName (c1 VARCHAR(32))");
|
||||
$stmt=null;
|
||||
|
||||
// Insert data
|
||||
$query = "INSERT INTO ".$tableName." VALUES ('Salmon'),('Butterfish'),('Cod'),('NULL'),('Crab')";
|
||||
$query = "INSERT INTO $tableName VALUES ('Salmon'),('Butterfish'),('Cod'),('NULL'),('Crab')";
|
||||
$stmt = $conn->query($query);
|
||||
$res[] = $stmt->rowCount();
|
||||
|
||||
// Update data
|
||||
$query = "UPDATE ".$tableName." SET c1='Salmon' WHERE c1='Cod'";
|
||||
$query = "UPDATE $tableName SET c1='Salmon' WHERE c1='Cod'";
|
||||
$stmt = $conn->query($query);
|
||||
$res[] = $stmt->rowCount();
|
||||
|
||||
// Update data
|
||||
$query = "UPDATE ".$tableName." SET c1='Salmon' WHERE c1='NULL'";
|
||||
$query = "UPDATE $tableName SET c1='Salmon' WHERE c1='NULL'";
|
||||
$stmt = $conn->query($query);
|
||||
$res[] = $stmt->rowCount();
|
||||
|
||||
// Update data
|
||||
$query = "UPDATE ".$tableName." SET c1='Salmon' WHERE c1='NO_NAME'";
|
||||
$query = "UPDATE $tableName SET c1='Salmon' WHERE c1='NO_NAME'";
|
||||
$stmt = $conn->query($query);
|
||||
$res[] = $stmt->rowCount();
|
||||
|
||||
// Update data
|
||||
$query = "UPDATE ".$tableName." SET c1='N/A'";
|
||||
$query = "UPDATE $tableName SET c1='N/A'";
|
||||
$stmt = $conn->query($query);
|
||||
$res[] = $stmt->rowCount();
|
||||
|
||||
print_r($res);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
$stmt=null;
|
||||
$conn=null;
|
||||
print "Done"
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
--TEST--
|
||||
Number MAX_INT to string with custom formats
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
/* Sample number MAX_INT */
|
||||
$sample = 2*(2**30-1)+1;
|
||||
var_dump ($sample);
|
||||
|
||||
/* Connect */
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// Create database
|
||||
$conn->query("CREATE DATABASE $dbName") ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$tableName = '#testCustomFormats';
|
||||
$query = "CREATE TABLE $tableName (col1 INT)";
|
||||
$stmt = $conn->query($query);
|
||||
$stmt = $conn->exec($query);
|
||||
|
||||
// Query number with custom format
|
||||
$query ="SELECT CAST($sample as varchar) + '.00'";
|
||||
|
@ -33,15 +32,11 @@ $stmt->execute();
|
|||
|
||||
// Fetching. Prepare with client buffered cursor
|
||||
$query = "SELECT TOP 1 cast(col1 as varchar) + '.00 EUR' FROM $tableName";
|
||||
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL,
|
||||
PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
|
||||
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
|
||||
$stmt->execute();
|
||||
$value = $stmt->fetchColumn();
|
||||
var_dump ($value);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
//Free the statement and connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
--TEST--
|
||||
Number MAX_INT to string with custom formats, see pdo_014. Pooling enabled.
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$pooling = true;
|
||||
|
||||
|
@ -11,19 +12,17 @@ $pooling = true;
|
|||
$sample = 2*(2**30-1)+1;
|
||||
|
||||
/* Connect + create a new pool */
|
||||
$conn0 = new PDO("sqlsrv:server=$serverName;ConnectionPooling=$pooling", $username, $password);
|
||||
$conn0 = new PDO("sqlsrv:server=$server;database=$databaseName;ConnectionPooling=$pooling", $uid, $pwd);
|
||||
$conn0->query("select 1");
|
||||
$conn0 = null;
|
||||
|
||||
/* Connect */
|
||||
$conn = new PDO("sqlsrv:server=$serverName;ConnectionPooling=$pooling", $username, $password);
|
||||
$conn = new PDO("sqlsrv:server=$server;database=$databaseName;ConnectionPooling=$pooling", $uid, $pwd);
|
||||
|
||||
// Create database
|
||||
$conn->query("CREATE DATABASE $dbName") ?: die();
|
||||
|
||||
// Create table
|
||||
// Create a temporary table
|
||||
$tableName = '#testFormats';
|
||||
$query = "CREATE TABLE $tableName (col1 INT)";
|
||||
$stmt = $conn->query($query);
|
||||
$stmt = $conn->exec($query);
|
||||
|
||||
// Query number with custom format
|
||||
$query ="SELECT CAST($sample as varchar) + '.00'";
|
||||
|
@ -39,15 +38,11 @@ $stmt->execute();
|
|||
|
||||
// Fetching. Prepare with client buffered cursor
|
||||
$query = "SELECT TOP 1 cast(col1 as varchar) + '.00 EUR' FROM $tableName";
|
||||
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL,
|
||||
PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
|
||||
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
|
||||
$stmt->execute();
|
||||
$value = $stmt->fetchColumn();
|
||||
var_dump ($value);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
//Free the statement and connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
--TEST--
|
||||
Bind integer parameters; allow fetch numeric types.
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
/* Sample numbers MIN_INT, MAX_INT */
|
||||
$sample = array(-2**31, 2**31-1);
|
||||
|
||||
/* Connect */
|
||||
$conn_ops['pdo'][PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE] = TRUE;
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password, $conn_ops['pdo']);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd, $conn_ops['pdo']);
|
||||
|
||||
// Create table
|
||||
$tableName = '#testPDO016';
|
||||
$sql = "CREATE TABLE $tableName (c1 INT, c2 INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
$sql = "INSERT INTO $tableName VALUES (:num1, :num2)";
|
||||
|
@ -32,9 +31,6 @@ $stmt = $conn->query($sql);
|
|||
$row = $stmt->fetch(PDO::FETCH_NUM);
|
||||
var_dump ($row);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
--TEST--
|
||||
Fetch string with new line and tab characters
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO( "sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$sql = "CREATE TABLE ".$tableName.
|
||||
" (c1 VARCHAR(32), c2 CHAR(32), c3 NVARCHAR(32), c4 NCHAR(32))";
|
||||
$stmt = $conn->query($sql);
|
||||
$tableName = '#pdo_017';
|
||||
$sql = "CREATE TABLE $tableName (c1 VARCHAR(32), c2 CHAR(32), c3 NVARCHAR(32), c4 NCHAR(32))";
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Bind parameters and insert data
|
||||
$sql = "INSERT INTO $tableName VALUES (:val1, :val2, :val3, :val4)";
|
||||
|
@ -28,14 +26,11 @@ $stmt->execute();
|
|||
|
||||
// Get data
|
||||
$sql = "SELECT UPPER(c1) AS VARCHAR, UPPER(c2) AS CHAR,
|
||||
UPPER(c3) AS NVARCHAR, UPPER(c4) AS NCHAR FROM $tableName";
|
||||
UPPER(c3) AS NVARCHAR, UPPER(c4) AS NCHAR FROM $tableName";
|
||||
$stmt = $conn->query($sql);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt=null;
|
||||
$conn=null;
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
--TEST--
|
||||
Moves the cursor to the next result set
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
/* Connect */
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$tableName = '#testResultSet';
|
||||
$sql = "CREATE TABLE $tableName (c1 INT, c2 VARCHAR(40))";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
|
@ -41,9 +40,6 @@ echo $a['c1'] . "|" . $a['c2'] . "\n";
|
|||
foreach ($data2 as $a)
|
||||
echo $a[0] . "|" . $a[1] . "\n";
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
--TEST--
|
||||
Moves the cursor to the next result set with pooling enabled
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Create a pool
|
||||
$conn0 = new PDO("sqlsrv:server=$serverName;ConnectionPooling=1", $username, $password);
|
||||
$conn0 = new PDO("sqlsrv:server=$server; database=$databaseName;ConnectionPooling=1", $uid, $pwd);
|
||||
$conn0->query("SELECT 1");
|
||||
$conn0 = null;
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName;ConnectionPooling=1", $username, $password);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName;ConnectionPooling=1", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$tableName = '#nextResultPooling';
|
||||
$sql = "CREATE TABLE $tableName (c1 INT, c2 XML)";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
|
@ -46,9 +45,6 @@ echo $a['c1']."|".$a['c2']."\n";
|
|||
foreach ($data2 as $a)
|
||||
echo $a[0] . "|".$a[1]."\n";
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
--TEST--
|
||||
Bind parameters using an array
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$tableName = '#bindParams';
|
||||
$sql = "CREATE TABLE $tableName (ID TINYINT, SID CHAR(5))";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
|
@ -41,9 +40,6 @@ $data = $stmt->fetchAll();
|
|||
foreach ($data as $a)
|
||||
echo $a['ID'] . "|" . $a['SID'] . "\n";
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
--TEST--
|
||||
Bind parameters VARCHAR(n) extended ASCII
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$tableName = '#extendedAscii';
|
||||
$sql = "CREATE TABLE $tableName (code CHAR(2), city VARCHAR(32))";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
|
@ -36,9 +35,6 @@ $data = $stmt->fetchAll();
|
|||
foreach ($data as $a)
|
||||
echo $a[0] . "|" . $a[1] . "\n";
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
--TEST--
|
||||
Unicode XML message using bindValue()
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName;", $username, $password);
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// Create database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Create table
|
||||
// Create a temporary table
|
||||
$tableName = '#testXMLBindValue';
|
||||
$sql = "CREATE TABLE $tableName (ID INT PRIMARY KEY NOT NULL IDENTITY, XMLMessage XML)";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// XML samples
|
||||
$xml1 = '<?xml version="1.0" encoding="UTF-16"?>
|
||||
|
@ -49,9 +48,6 @@ $stmt = $conn->query("select * from $tableName");
|
|||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
|
||||
// Drop database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt=null;
|
||||
$conn=null;
|
||||
|
|
|
@ -3,16 +3,13 @@ Bind values with PDO::PARAM_BOOL, enable/disable fetch numeric type attribute
|
|||
--SKIPIF--
|
||||
--FILE--
|
||||
<?php
|
||||
require("autonomous_setup.php");
|
||||
require("MsSetup.inc");
|
||||
|
||||
// Sample data
|
||||
$sample = array([true, false],[-12, 0x2A],[0.00, NULL]);
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// Create database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Run test
|
||||
Test();
|
||||
|
@ -25,9 +22,6 @@ Test();
|
|||
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, TRUE);
|
||||
Test();
|
||||
|
||||
// Drop database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
@ -37,33 +31,33 @@ print "Done";
|
|||
// Generic test starts here
|
||||
function Test()
|
||||
{
|
||||
global $conn, $tableName, $sample;
|
||||
global $conn, $tableName, $sample;
|
||||
|
||||
// Drop table if exists
|
||||
$sql = "IF OBJECT_ID('$tableName') IS NOT NULL DROP TABLE $tableName";
|
||||
$stmt = $conn->query($sql);
|
||||
// Drop table if exists
|
||||
$sql = "IF OBJECT_ID('$tableName') IS NOT NULL DROP TABLE $tableName";
|
||||
$stmt = $conn->query($sql);
|
||||
|
||||
// Create table
|
||||
$sql = "CREATE TABLE $tableName (c1 INT, c2 BIT)";
|
||||
$stmt = $conn->query($sql) ?: die();
|
||||
// Create table
|
||||
$sql = "CREATE TABLE $tableName (c1 INT, c2 BIT)";
|
||||
$stmt = $conn->query($sql) ?: die();
|
||||
|
||||
// Insert data using bind values
|
||||
$sql = "INSERT INTO $tableName VALUES (:v1, :v2)";
|
||||
foreach ($sample as $s) {
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bindValue(':v1', $s[0], PDO::PARAM_BOOL);
|
||||
$stmt->bindValue(':v2', $s[1], PDO::PARAM_BOOL);
|
||||
$stmt->execute();
|
||||
}
|
||||
// Insert data using bind values
|
||||
$sql = "INSERT INTO $tableName VALUES (:v1, :v2)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
foreach ($sample as $s) {
|
||||
$stmt->bindValue(':v1', $s[0], PDO::PARAM_BOOL);
|
||||
$stmt->bindValue(':v2', $s[1], PDO::PARAM_BOOL);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
// Get data
|
||||
$sql = "SELECT * FROM $tableName";
|
||||
$stmt = $conn->query($sql);
|
||||
$row = $stmt->fetchAll(PDO::FETCH_NUM);
|
||||
// Get data
|
||||
$sql = "SELECT * FROM $tableName";
|
||||
$stmt = $conn->query($sql);
|
||||
$row = $stmt->fetchAll(PDO::FETCH_NUM);
|
||||
|
||||
// Print out
|
||||
for($i=0; $i<$stmt->rowCount(); $i++)
|
||||
{ var_dump($row[$i][0]); var_dump($row[$i][1]); }
|
||||
// Print out
|
||||
for($i=0; $i<$stmt->rowCount(); $i++)
|
||||
{ var_dump($row[$i][0]); var_dump($row[$i][1]); }
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
--TEST--
|
||||
GitHub Issue #35 binary encoding error when binding by name
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
function test()
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$dbName = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:server=$serverName ; database=$dbName", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server ; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create a temp table
|
||||
$number = rand(0,1000);
|
||||
$tableName = "testTableIssue35" . "_" . $number;
|
||||
$tableName = "#testTableIssue35";
|
||||
$sql = "CREATE TABLE $tableName (Value varbinary(max))";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
$sql = "INSERT INTO $tableName VALUES (?)";
|
||||
|
@ -34,8 +33,6 @@ function test()
|
|||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
var_dump($val1 === $value);
|
||||
|
||||
$stmt = $conn->query("DROP TABLE $tableName");
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
--TEST--
|
||||
Retrieve error information; supplied values does not match table definition
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
// Create table
|
||||
$tableName = '#pdo_040test';
|
||||
$sql = "CREATE TABLE $tableName (code INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data using bind parameters
|
||||
// Number of supplied values does not match table definition
|
||||
|
@ -25,9 +24,6 @@ $params = array(2010,"London");
|
|||
$stmt->execute($params);
|
||||
print_r($stmt->errorInfo());
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
// Close connection
|
||||
$stmt = null;
|
||||
$conn = null;
|
||||
|
|
|
@ -1,56 +1,55 @@
|
|||
--TEST--
|
||||
Prepare, execute statement and fetch with pooling unset (default)
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Allow PHP types for numeric fields
|
||||
$connection_options['pdo'][PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE] = TRUE;
|
||||
|
||||
// Create a pool
|
||||
$conn0 = new PDO( "sqlsrv:server=$serverName;",
|
||||
$username, $password, $connection_options['pdo']);
|
||||
$conn0 = new PDO( "sqlsrv:server=$server;database=$databaseName;",
|
||||
$uid, $pwd, $connection_options['pdo']);
|
||||
$conn0 = null;
|
||||
|
||||
// Connection can use an existing pool
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;",
|
||||
$username, $password, $connection_options['pdo']);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;",
|
||||
$uid, $pwd, $connection_options['pdo']);
|
||||
|
||||
// Create table
|
||||
$tableName = 'pdo_060_test';
|
||||
$sql = "CREATE TABLE $tableName (Столица NVARCHAR(32), year INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
|
||||
// Insert data
|
||||
$sql = "INSERT INTO ".$tableName." VALUES (?,?)";
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute(array("Лондон",2012));
|
||||
|
||||
// Get data
|
||||
$stmt = $conn->query("select * from $tableName");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
$conn = null;
|
||||
|
||||
// Create a new pool
|
||||
$conn0 = new PDO( "sqlsrv:server=$serverName;",
|
||||
$username, $password);
|
||||
$conn0 = new PDO( "sqlsrv:server=$server;database=$databaseName;",
|
||||
$uid, $pwd);
|
||||
$conn0 = null;
|
||||
|
||||
// Connection can use an existing pool
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;",
|
||||
$username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;",
|
||||
$uid, $pwd);
|
||||
|
||||
// Get data
|
||||
$stmt = $conn->query("select * from $tableName");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
$conn->query("DROP TABLE $tableName");
|
||||
|
||||
// Close connection
|
||||
$stmt=null;
|
||||
|
|
|
@ -1,56 +1,54 @@
|
|||
--TEST--
|
||||
Prepare, execute statement and fetch with pooling enabled
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Allow PHP types for numeric fields
|
||||
$connection_options['pdo'][PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE] = TRUE;
|
||||
|
||||
// Create a pool
|
||||
$conn0 = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=1;",
|
||||
$username, $password, $connection_options['pdo']);
|
||||
$conn0 = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=1;",
|
||||
$uid, $pwd, $connection_options['pdo']);
|
||||
$conn0 = null;
|
||||
|
||||
// Connection can use an existing pool
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=1;",
|
||||
$username, $password, $connection_options['pdo']);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=1;",
|
||||
$uid, $pwd, $connection_options['pdo']);
|
||||
|
||||
// Create table
|
||||
$tableName = 'pdo_061test';
|
||||
$sql = "CREATE TABLE $tableName (Столица NVARCHAR(32), year INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
|
||||
// Insert data
|
||||
$sql = "INSERT INTO ".$tableName." VALUES (?,?)";
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute(array("Лондон",2012));
|
||||
|
||||
// Get data
|
||||
$stmt = $conn->query("select * from $tableName");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
$conn = null;
|
||||
|
||||
// Create a new pool
|
||||
$conn0 = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=1;",
|
||||
$username, $password);
|
||||
$conn0 = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=1;",
|
||||
$uid, $pwd);
|
||||
$conn0 = null;
|
||||
|
||||
// Connection can use an existing pool
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=1;",
|
||||
$username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=1;",
|
||||
$uid, $pwd);
|
||||
|
||||
// Get data
|
||||
$stmt = $conn->query("select * from $tableName");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
$conn->query("DROP TABLE $tableName");
|
||||
|
||||
// Close connection
|
||||
$stmt=null;
|
||||
|
|
|
@ -1,56 +1,55 @@
|
|||
--TEST--
|
||||
Prepare, execute statement and fetch with pooling disabled
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Allow PHP types for numeric fields
|
||||
$connection_options['pdo'][PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE] = TRUE;
|
||||
|
||||
// Create a pool
|
||||
$conn0 = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=0;",
|
||||
$username, $password, $connection_options['pdo']);
|
||||
$conn0 = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=0;",
|
||||
$uid, $pwd, $connection_options['pdo']);
|
||||
$conn0 = null;
|
||||
|
||||
// Connection can use an existing pool
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=0;",
|
||||
$username, $password, $connection_options['pdo']);
|
||||
|
||||
// CREATE database
|
||||
$conn->query("CREATE DATABASE ". $dbName) ?: die();
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=0;",
|
||||
$uid, $pwd, $connection_options['pdo']);
|
||||
|
||||
// Create table
|
||||
$tableName = 'pdo_62test';
|
||||
$sql = "CREATE TABLE $tableName (Столица NVARCHAR(32), year INT)";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
|
||||
// Insert data
|
||||
$sql = "INSERT INTO ".$tableName." VALUES (?,?)";
|
||||
$sql = "INSERT INTO $tableName VALUES (?,?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute(array("Лондон",2012));
|
||||
|
||||
// Get data
|
||||
$stmt = $conn->query("select * from $tableName");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
$conn = null;
|
||||
|
||||
// Create a new pool
|
||||
$conn0 = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=0;",
|
||||
$username, $password);
|
||||
$conn0 = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=0;",
|
||||
$uid, $pwd);
|
||||
$conn0 = null;
|
||||
|
||||
// Connection can use an existing pool
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;ConnectionPooling=0;",
|
||||
$username, $password);
|
||||
// Connection can use an existing pool?
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;ConnectionPooling=0;",
|
||||
$uid, $pwd);
|
||||
|
||||
// Get data
|
||||
$stmt = $conn->query("select * from $tableName");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName");
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
var_dump($row);
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
|
||||
$conn->query("DROP TABLE $tableName");
|
||||
|
||||
// Close connection
|
||||
$stmt=null;
|
||||
|
|
|
@ -1,36 +1,37 @@
|
|||
--TEST--
|
||||
Exception is thrown if the unsupported attribute ATTR_PERSISTENT is put into the connection options
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'pdo_tools.inc';
|
||||
require_once("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName;Database = $database;";
|
||||
include 'MsSetup.inc';
|
||||
$dsn = "sqlsrv:Server = $server;database = $databaseName;";
|
||||
try{
|
||||
echo "Testing a connection with ATTR_PERSISTENT...\n";
|
||||
// setting PDO::ATTR_PERSISTENT in PDO constructor returns an exception
|
||||
$attr = array(PDO::ATTR_PERSISTENT => true);
|
||||
$conn = new PDO( $dsn, $username, $password, $attr);
|
||||
$conn = new PDO( $dsn, $uid, $pwd, $attr);
|
||||
|
||||
//free the connection
|
||||
$conn=null;
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
echo "Exception from unsupported attribute (ATTR_PERSISTENT) is caught\n";
|
||||
//exit;
|
||||
}
|
||||
try{
|
||||
|
||||
require_once 'MsCommon.inc';
|
||||
|
||||
echo "\nTesting new connection after exception thrown in previous connection...\n";
|
||||
$tableName1 = GetTempTableName('tab1', false);
|
||||
$conn = new PDO( $dsn, $username, $password );
|
||||
$tableName1 = GetTempTableName('tab1');
|
||||
$conn = new PDO( $dsn, $uid, $pwd );
|
||||
$sql = "CREATE TABLE $tableName1 (c1 int, c2 varchar(10))";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt = $conn->exec($sql);
|
||||
$ret = $conn->exec("INSERT INTO $tableName1 VALUES(1, 'column2')");
|
||||
$stmt = $conn->query("SELECT * FROM $tableName1");
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result['c1'] == 1 && $result['c2'] == 'column2') {
|
||||
echo "Test successfully";
|
||||
echo "Test successfully completed";
|
||||
}
|
||||
//free the statement and connection
|
||||
$stmt = null;
|
||||
|
@ -45,4 +46,4 @@ Testing a connection with ATTR_PERSISTENT...
|
|||
Exception from unsupported attribute (ATTR_PERSISTENT) is caught
|
||||
|
||||
Testing new connection after exception thrown in previous connection...
|
||||
Test successfully
|
||||
Test successfully completed
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
--TEST--
|
||||
Test unsupported connection attribute ATTR_PREFETCH
|
||||
--DESCRIPTION--
|
||||
Exception is thrown for the unsupported connection attribute ATTR_PREFETCH only if it is set after PDO::ERRMODE_EXCEPTION is turned on
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'pdo_tools.inc';
|
||||
require_once("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName;Database = $database;";
|
||||
require_once("MsSetup.inc");
|
||||
$dsn = "sqlsrv:Server = $server;database = $databaseName";
|
||||
try{
|
||||
echo "Testing a connection with ATTR_PREFETCH before ERRMODE_EXCEPTION...\n";
|
||||
$attr = array(PDO::ATTR_PREFETCH => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
|
||||
$conn = new PDO( $dsn, $username, $password, $attr);
|
||||
$conn = new PDO( $dsn, $uid, $pwd, $attr);
|
||||
echo "Error from supported attribute (ATTR_PREFETCH) is silented\n\n";
|
||||
$conn=null;
|
||||
|
||||
echo "Testing a connection with ATTR_PREFETCH after ERRMODE_EXCEPTION...\n";
|
||||
$attr = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_PREFETCH => true);
|
||||
$conn = new PDO( $dsn, $username, $password, $attr);
|
||||
$conn = new PDO( $dsn, $uid, $pwd, $attr);
|
||||
//free the connection
|
||||
$conn=null;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
--TEST--
|
||||
GitHub issue #69 - fetching an empty nvarchar using client buffer
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
// Connect
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$sql = "EXEC dbo.sp_executesql
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
--TEST--
|
||||
sqlsrv_has_rows() using a forward and scrollable cursor
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO( "sqlsrv:server=$serverName" , $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server; database=$databaseName" , $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
// Create database
|
||||
$conn->query("CREATE DATABASE ". $dbName);
|
||||
// Create table
|
||||
$stmt = $conn->query("CREATE TABLE ".$dbName.".[dbo].[php_test_table_1] ([c1_int] int, [c2_varchar] varchar(1000))");
|
||||
$query = "INSERT INTO ".$dbName.".[dbo].[php_test_table_1] (c1_int, c2_varchar) VALUES ((990021574), ('>vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb</üöîã,ZbOhߢAåb*öî:r>:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<<AA*¢ã@Uî:B<öBîÐ>z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>å<býUrAA©r£@üÄb_:ãZß_/ou@|ªåü~ACãUO<£îßÄîäbßöhßO©ZvßOBü:Zä<ĪobbO@ÃÐ_~î|a~ð©+,v+Ð/rÃzuöÖZÐOß/CCÖßý¢:<b£B,ÐߢoZbð~BüOö,Üö~ð:ß,CCî<Oä,Öãî£ÜCZ~/z~ý©vuzoöß/u©å|£ãÐv¢îhý:ÄoÐrz.ßbr_U*<hCîßÖ_+:hbü*að.Aö_Oª_öB>Bã_ý*ah¢rOĪ,ßo¢¢a|BÖäz</bUabÖðOA.Ðîý,Bhö*Cßuߣo,|ü_,ýÐu_b|ZÜh|<U@~übU¢Uð/o/Ð>U£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£'))";
|
||||
// Create temporary table2
|
||||
$tableName1 = '#pdo_228_1';
|
||||
$tableName2 = '#pdo_228_2';
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName1 ([c1_int] int, [c2_varchar] varchar(1000))");
|
||||
$query = "INSERT INTO $tableName1 (c1_int, c2_varchar) VALUES ((990021574), ('>vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb</üöîã,ZbOhߢAåb*öî:r>:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<<AA*¢ã@Uî:B<öBîÐ>z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>å<býUrAA©r£@üÄb_:ãZß_/ou@|ªåü~ACãUO<£îßÄîäbßöhßO©ZvßOBü:Zä<ĪobbO@ÃÐ_~î|a~ð©+,v+Ð/rÃzuöÖZÐOß/CCÖßý¢:<b£B,ÐߢoZbð~BüOö,Üö~ð:ß,CCî<Oä,Öãî£ÜCZ~/z~ý©vuzoöß/u©å|£ãÐv¢îhý:ÄoÐrz.ßbr_U*<hCîßÖ_+:hbü*að.Aö_Oª_öB>Bã_ý*ah¢rOĪ,ßo¢¢a|BÖäz</bUabÖðOA.Ðîý,Bhö*Cßuߣo,|ü_,ýÐu_b|ZÜh|<U@~übU¢Uð/o/Ð>U£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£'))";
|
||||
$stmt = $conn->query($query);
|
||||
|
||||
$stmt = $conn->query("CREATE TABLE ".$dbName.".[dbo].[php_test_table_2] ([c1_int] int, [c2_varchar] varchar(max))");
|
||||
$query = "INSERT INTO ".$dbName.".[dbo].[php_test_table_2] (c1_int, c2_varchar) VALUES ((990021574), ('>vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb</üöîã,ZbOhߢAåb*öî:r>:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<<AA*¢ã@Uî:B<öBîÐ>z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>å<býUrAA©r£@üÄb_:ãZß_/ou@|ªåü~ACãUO<£îßÄîäbßöhßO©ZvßOBü:Zä<ĪobbO@ÃÐ_~î|a~ð©+,v+Ð/rÃzuöÖZÐOß/CCÖßý¢:<b£B,ÐߢoZbð~BüOö,Üö~ð:ß,CCî<Oä,Öãî£ÜCZ~/z~ý©vuzoöß/u©å|£ãÐv¢îhý:ÄoÐrz.ßbr_U*<hCîßÖ_+:hbü*að.Aö_Oª_öB>Bã_ý*ah¢rOĪ,ßo¢¢a|BÖäz</bUabÖðOA.Ðîý,Bhö*Cßuߣo,|ü_,ýÐu_b|ZÜh|<U@~übU¢Uð/o/Ð>U£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£'))";
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName2 ([c1_int] int, [c2_varchar] varchar(max))");
|
||||
$query = "INSERT INTO $tableName2 (c1_int, c2_varchar) VALUES ((990021574), ('>vh~Ö.bÐ*äß/ÄAabýZâOüzr£ðAß+|~|OU¢a|U<ßrv.uCB.ÐÜh_î+ãå@üðöã,U+ßvuU:/ý_Öãî/ð|bB|_Zbua©r++BA¢z£.üî¢öåäözÜ¢ßb</üöîã,ZbOhߢAåb*öî:r>:aöCrÄ~ýZ¢uªÐö.hhßð*zÜÜß*ãüåýãÄ+åýüüaߢÃÐBî@~AZöÃOßC@äoÃuCÜ,ÐÄa:îäÄÖý:h*ouªuåvUz_ArßAªãaãvÐåAUüAB:¢Äz|öub<üZvößüå:ãÄ@r/ZAÄðÄÄvzîv~C/£|ýýbüÖ~£|Öå<Üa~/v@åAz©¢£U_ßhbaÃß,zz<ã¢|<ä©>öAuövÖ>abu,zå,+ß/ü/ª_bbB:ÃC~£ü/O©O©ªAª_,|a¢~ýý/b>ßC@/böîöh>~£ð+Bßr©ÄÐÖßã:bA@:>B:UAbããîÜ~uÜ£îCöÖ£©_ÜßzÐ+ÖýZb,A:<<AA*¢ã@Uî:B<öBîÐ>z.ãîÄzC@©*ä|ã._ßZOäb¢Cßovå+uv.£B~~b£ª|ÖÄîßö>©Ãbb|©©ðA£åO~âãüîuvÄÜýUzîOÖ/oOßO*>ªßzêÖÐböÄåbîðîÐa~©ßîÄßУ<î>å<býUrAA©r£@üÄb_:ãZß_/ou@|ªåü~ACãUO<£îßÄîäbßöhßO©ZvßOBü:Zä<ĪobbO@ÃÐ_~î|a~ð©+,v+Ð/rÃzuöÖZÐOß/CCÖßý¢:<b£B,ÐߢoZbð~BüOö,Üö~ð:ß,CCî<Oä,Öãî£ÜCZ~/z~ý©vuzoöß/u©å|£ãÐv¢îhý:ÄoÐrz.ßbr_U*<hCîßÖ_+:hbü*að.Aö_Oª_öB>Bã_ý*ah¢rOĪ,ßo¢¢a|BÖäz</bUabÖðOA.Ðîý,Bhö*Cßuߣo,|ü_,ýÐu_b|ZÜh|<U@~übU¢Uð/o/Ð>U£.B£@Ü,ßAÃ>,ðßß+ßÜ©|Ðr©bCðТüãz>AßðåÃ>bÄåÄ|Z~äÃ/Cb*£bð_/Ða@~AÜãO+ý*CîîÃzÄöÃa©+@vuz>î>©.Cv>hÃý>©Bä,ö~@~@r,AðCu@Ü,@U*ÐvöÃêuã.Öa*uZªoZ/ðÖ©ßv_<ÖvåÜÐÜOÐoðßðÃUýZÐB:+ÄÃã£'))";
|
||||
$stmt = $conn->query($query);
|
||||
|
||||
$size = 2;
|
||||
$stmt = $conn->prepare("SELECT * FROM ".$dbName.".[dbo].[php_test_table_1]", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size));
|
||||
$stmt = $conn->prepare("SELECT * FROM $tableName1", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size));
|
||||
$attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE'));
|
||||
echo("Client Buffer Size in KB: $attr\n");
|
||||
$stmt->execute();
|
||||
$numRows = 0;
|
||||
while ($result = $stmt->fetch())
|
||||
$numRows++;
|
||||
$numRows++;
|
||||
|
||||
echo ("Number of rows: $numRows\n");
|
||||
|
||||
$size = 3;
|
||||
$stmt = $conn->prepare("SELECT * FROM ".$dbName.".[dbo].[php_test_table_2]", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size));
|
||||
$stmt = $conn->prepare("SELECT * FROM $tableName2", array(constant('PDO::ATTR_CURSOR') => PDO::CURSOR_SCROLL,PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED,PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE=> $size));
|
||||
$attr = $stmt->getAttribute(constant('PDO::SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE'));
|
||||
echo("Client Buffer Size in KB: $attr\n");
|
||||
$stmt->execute();
|
||||
$numRows = 0;
|
||||
while ($result = $stmt->fetch())
|
||||
$numRows++;
|
||||
$numRows++;
|
||||
|
||||
echo ("Number of rows: $numRows\n");
|
||||
|
||||
// DROP database
|
||||
$conn->query("DROP DATABASE ". $dbName) ?: die();
|
||||
$stmt=null;
|
||||
$conn=null;
|
||||
print "Done"
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
--TEST--
|
||||
Test closeCursor with a stmt before/after execute and fetch.
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
/* Connect */
|
||||
$conn = new PDO("sqlsrv:server=$serverName", $username, $password);
|
||||
// Connect
|
||||
$conn = new PDO("sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
// prepare a stmt but don't execute, then closeCursor.
|
||||
|
@ -52,7 +53,7 @@ try
|
|||
|
||||
catch( PDOException $e ) {
|
||||
var_dump($e);
|
||||
exit;
|
||||
exit;
|
||||
}
|
||||
|
||||
print "Done";
|
||||
|
|
|
@ -3,17 +3,18 @@ Test fetch from binary, varbinary, varbinary(max), image columns, without settin
|
|||
--DESCRIPTION--
|
||||
Verifies GitHub issue 270 is fixed, users could not retrieve the data as inserted in binary columns without setting the binary encoding either on stmt or using bindCoulmn encoding.
|
||||
This test verifies that the data inserted in binary columns can be retrieved using fetch, fetchColumn, fetchObject, and fetchAll functions.
|
||||
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$tableName = 'test_binary'.rand();
|
||||
$columns = array( 'col1', 'col2', 'col3', 'col4');
|
||||
|
||||
// Connect
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=tempdb", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:server=$server; database=$databaseName", $uid, $pwd );
|
||||
|
||||
$sql = "CREATE TABLE $tableName ( $columns[0] binary(50), $columns[1] VARBINARY(50), $columns[2] VARBINARY(MAX), $columns[3] image)";
|
||||
$conn->exec($sql);
|
||||
|
@ -31,7 +32,7 @@ $stmt->execute();
|
|||
|
||||
// loop through each column in the table
|
||||
foreach ($columns as $col){
|
||||
test_fetch($conn, $tableName, $col, $icon);
|
||||
test_fetch($conn, $tableName, $col, $icon);
|
||||
}
|
||||
// DROP table
|
||||
$conn->query("DROP TABLE $tableName") ?: die();
|
||||
|
@ -45,46 +46,46 @@ print_r("Test finished successfully");
|
|||
//calls various fetch methods
|
||||
function test_fetch($conn, $tableName, $columnName, $input){
|
||||
|
||||
$len = strlen($input);
|
||||
$result = "";
|
||||
$sql = "SELECT $columnName from $tableName";
|
||||
$len = strlen($input);
|
||||
$result = "";
|
||||
$sql = "SELECT $columnName from $tableName";
|
||||
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt->bindColumn(1, $result, PDO::PARAM_LOB);
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
//binary is fixed size, to evaluate output, compare it using strncmp
|
||||
if( strncmp($result, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using bindColumn failed");
|
||||
}
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt->bindColumn(1, $result, PDO::PARAM_LOB);
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
//binary is fixed size, to evaluate output, compare it using strncmp
|
||||
if( strncmp($result, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using bindColumn failed");
|
||||
}
|
||||
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt->bindColumn(1, $result, PDO::PARAM_LOB, 0 , PDO::SQLSRV_ENCODING_BINARY);
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
if( strncmp($result, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using bindColumn with encoding set failed");
|
||||
}
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$stmt->bindColumn(1, $result, PDO::PARAM_LOB, 0 , PDO::SQLSRV_ENCODING_BINARY);
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
if( strncmp($result, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using bindColumn with encoding set failed");
|
||||
}
|
||||
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$result = $stmt->fetchColumn();
|
||||
if( strncmp($result, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using fetchColumn failed");
|
||||
}
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$result = $stmt->fetchColumn();
|
||||
if( strncmp($result, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using fetchColumn failed");
|
||||
}
|
||||
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$result = $stmt->fetchObject();
|
||||
if( strncmp($result->$columnName, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using fetchObject failed");
|
||||
}
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$result = $stmt->fetchObject();
|
||||
if( strncmp($result->$columnName, $input, $len) !== 0){
|
||||
print_r("\nRetrieving using fetchObject failed");
|
||||
}
|
||||
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$result = $stmt->fetchAll( PDO::FETCH_COLUMN );
|
||||
if( strncmp($result[0], $input, $len) !== 0){
|
||||
print_r("\nRetrieving using fetchAll failed");
|
||||
}
|
||||
$result = "";
|
||||
$stmt = $conn->query($sql);
|
||||
$result = $stmt->fetchAll( PDO::FETCH_COLUMN );
|
||||
if( strncmp($result[0], $input, $len) !== 0){
|
||||
print_r("\nRetrieving using fetchAll failed");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -3,16 +3,14 @@ GitHub issue #308 - empty string set to output parameter on stored procedure
|
|||
--DESCRIPTION--
|
||||
Verifies GitHub issue 308 is fixed, empty string returned as output parameter will remain an empty string.
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("pdo_tools.inc");
|
||||
require_once("MsCommon.inc");
|
||||
|
||||
// Connect
|
||||
require_once("autonomous_setup.php");
|
||||
|
||||
$dbName = "tempdb";
|
||||
|
||||
$conn = new PDO("sqlsrv:server=$serverName;Database=$dbName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO("sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$procName = GetTempProcName();
|
||||
|
|
|
@ -3,13 +3,13 @@ GitHub issue #336 - PDO::exec should not return an error with query returning SQ
|
|||
--DESCRIPTION--
|
||||
Verifies GitHub issue 336 is fixed, PDO::exec on query returning SQL_NO_DATA will not give an error
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
// Connect
|
||||
require_once("autonomous_setup.php");
|
||||
$dbName = "tempdb";
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO("sqlsrv:server=$serverName;Database=$dbName", $username, $password);
|
||||
$conn = new PDO("sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$sql = "DELETE FROM foo_table WHERE id = 42";
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
--TEST--
|
||||
testing the quote method with different inputs and then test with a empty query
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function Quote()
|
||||
{
|
||||
require("autonomous_setup.php");
|
||||
require("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server; database=$databaseName", $uid, $pwd);
|
||||
|
||||
$output1 = $conn->quote("1'2'3'4'5'6'7'8", PDO::PARAM_INT);
|
||||
var_dump($output1);
|
||||
|
@ -48,6 +48,7 @@ function Quote()
|
|||
function Repro()
|
||||
{
|
||||
StartTest("pdo_connection_quote");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
Quote();
|
||||
|
@ -65,10 +66,10 @@ Repro();
|
|||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_connection_quote' test...
|
||||
Starting test...
|
||||
string(24) "'1''2''3''4''5''6''7''8'"
|
||||
string(16) "'{ABCD}''{EFGH}'"
|
||||
string(118) "'<XmlTestData><Letters>The quick brown fox jumps over the lazy dog</Letters><Digits>0123456789</Digits></XmlTestData>'"
|
||||
|
||||
Done
|
||||
...Test 'pdo_connection_quote' completed successfully.
|
||||
Test "pdo_connection_quote" completed successfully.
|
||||
|
|
|
@ -4,15 +4,15 @@ Test the connection resiliency keywords ConnectRetryCount and ConnectRetryInterv
|
|||
<?php if ( !( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' ) ) die( "Skip, not running on windows." ); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once( "autonomous_setup.php" );
|
||||
require_once( "MsSetup.inc" );
|
||||
|
||||
function TryToConnect( $serverName, $username, $password, $retryCount, $retryInterval, $number )
|
||||
function TryToConnect( $server, $uid, $pwd, $retryCount, $retryInterval, $number )
|
||||
{
|
||||
$connectionInfo = "ConnectRetryCount = $retryCount; ConnectRetryInterval = $retryInterval;";
|
||||
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:server = $serverName ; $connectionInfo", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
|
||||
echo "Connected successfully on $number attempt.\n";
|
||||
$conn = null;
|
||||
}
|
||||
|
@ -24,19 +24,19 @@ function TryToConnect( $serverName, $username, $password, $retryCount, $retryInt
|
|||
}
|
||||
}
|
||||
|
||||
TryToConnect( $serverName, $username, $password, 10, 30, 'first');
|
||||
TryToConnect( $serverName, $username, $password, 0, 30, 'second');
|
||||
TryToConnect( $serverName, $username, $password, 256, 30, 'third');
|
||||
TryToConnect( $serverName, $username, $password, 5, 70, 'fourth');
|
||||
TryToConnect( $serverName, $username, $password, -1, 30, 'fifth');
|
||||
TryToConnect( $serverName, $username, $password, 'thisisnotaninteger', 30, 'sixth');
|
||||
TryToConnect( $serverName, $username, $password, 5, 3.14159, 'seventh');
|
||||
TryToConnect( $server, $uid, $pwd, 10, 30, 'first');
|
||||
TryToConnect( $server, $uid, $pwd, 0, 30, 'second');
|
||||
TryToConnect( $server, $uid, $pwd, 256, 30, 'third');
|
||||
TryToConnect( $server, $uid, $pwd, 5, 70, 'fourth');
|
||||
TryToConnect( $server, $uid, $pwd, -1, 30, 'fifth');
|
||||
TryToConnect( $server, $uid, $pwd, 'thisisnotaninteger', 30, 'sixth');
|
||||
TryToConnect( $server, $uid, $pwd, 5, 3.14159, 'seventh');
|
||||
|
||||
$connectionInfo = "ConnectRetryCount;";
|
||||
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:server = $serverName ; $connectionInfo", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
|
||||
echo "Connected successfully on eighth attempt.\n";
|
||||
$conn = null;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ $connectionInfo = "ConnectRetryInterval;";
|
|||
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:server = $serverName ; $connectionInfo", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
|
||||
echo "Connected successfully on ninth attempt.\n";
|
||||
$conn = null;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
--TEST--
|
||||
Test PDO::__Construct connection option TransactionIsolation
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
function Connect($value) {
|
||||
require("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName;" .
|
||||
"Database = $database;" .
|
||||
require("MsSetup.inc");
|
||||
$dsn = "sqlsrv:Server = $server;" .
|
||||
"database = $databaseName;" .
|
||||
"TransactionIsolation = $value";
|
||||
$conn = new PDO( $dsn, $username, $password );
|
||||
$conn = new PDO( $dsn, $uid, $pwd );
|
||||
$conn = NULL;
|
||||
echo "Test Successful\n";
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
--TEST--
|
||||
Test PDO::__Construct by passing different connection attributes
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -21,10 +21,9 @@ try
|
|||
PDO::SQLSRV_ATTR_DIRECT_QUERY => true
|
||||
);
|
||||
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, $attr);
|
||||
$conn = new PDO( $dsn, $uid, $pwd, $attr);
|
||||
|
||||
$stmt = $conn->prepare("SELECT 1");
|
||||
$stmt->execute();
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
--TEST--
|
||||
Test PDO::__Construct by passing connection options
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName;" .
|
||||
$dsn = "sqlsrv:Server = $server;" .
|
||||
"ConnectionPooling = false;" .
|
||||
"APP = whatever;" .
|
||||
"LoginTimeout = 1;" .
|
||||
"ApplicationIntent = ReadOnly;" .
|
||||
"Database = $database;" .
|
||||
"database = $databaseName;" .
|
||||
"Encrypt = false;" .
|
||||
"Failover_Partner = whatever;" .
|
||||
"MultipleActiveResultSets = true;" .
|
||||
|
@ -26,8 +25,7 @@ try
|
|||
"TrustServerCertificate = false;" .
|
||||
"WSID = whatever;"
|
||||
;
|
||||
$conn = new PDO( $dsn, $username, $password);
|
||||
|
||||
$conn = new PDO( $dsn, $uid, $pwd);
|
||||
|
||||
echo "Test Successful";
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
--TEST--
|
||||
Test PDO::__Construct with incorrectly formatted DSN or no Server specified in DSN
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
/*----------Connection option cases that raises errors----------*/
|
||||
//dsn with 2 consecutive semicolons
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server = $serverName;;", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server = $server;;", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -21,7 +21,7 @@ catch( PDOException $e ) {
|
|||
//dsn with double right curly braces
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server =$serverName; Database = {tempdb}}", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server =$server; database = {tempdb}}", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -31,7 +31,7 @@ catch( PDOException $e ) {
|
|||
//dsn with double right curly braces and semicolon
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server =$serverName; Database = {tempdb}};", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server =$server; database = {tempdb}};", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -41,7 +41,7 @@ catch( PDOException $e ) {
|
|||
//dsn with right curly braces and other symbol
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server =$serverName; Database = {tempdb}?", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server =$server; database = {tempdb}?", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -51,7 +51,7 @@ catch( PDOException $e ) {
|
|||
//dsn with no equal sign in one option
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server =$serverName; Database", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server =$server; database", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -62,7 +62,7 @@ catch( PDOException $e ) {
|
|||
try
|
||||
{
|
||||
// Try to connect with no server specific
|
||||
@$conn = new PDO( "sqlsrv:", $username, $password );
|
||||
@$conn = new PDO( "sqlsrv:", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -71,8 +71,8 @@ catch( PDOException $e ) {
|
|||
// Try to connect with no server specified
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
@$conn = new PDO( "sqlsrv:Database = $database", $username, $password );
|
||||
$databaseName = "tempdb";
|
||||
@$conn = new PDO( "sqlsrv:database = $databaseName", $uid, $pwd );
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
print_r( ($e->errorInfo)[2] );
|
||||
|
@ -85,19 +85,19 @@ echo "\n";
|
|||
try
|
||||
{
|
||||
//dsn with curly braces
|
||||
$conn = new PDO( "sqlsrv:Server =$serverName; Database = {tempdb}", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server =$server; database = {tempdb}", $uid, $pwd );
|
||||
echo "value in curly braces OK\n";
|
||||
|
||||
//dsn with curly braces and semicolon
|
||||
@$conn = new PDO( "sqlsrv:Server =$serverName; Database = {tempdb};", $username, $password );
|
||||
@$conn = new PDO( "sqlsrv:Server =$server; database = {tempdb};", $uid, $pwd );
|
||||
echo "value in curly braces followed by a semicolon OK\n";
|
||||
|
||||
//dsn with curly braces and trailing spaces
|
||||
@$conn = new PDO( "sqlsrv:Server =$serverName; Database = {tempdb} ", $username, $password );
|
||||
@$conn = new PDO( "sqlsrv:Server =$server; database = {tempdb} ", $uid, $pwd );
|
||||
echo "value in curly braces followed by trailing spaces OK\n";
|
||||
|
||||
//dsn with no value specified and ends with semicolon
|
||||
$conn = new PDO( "sqlsrv:Server =$serverName; Database = ;", $username, $password );
|
||||
$conn = new PDO( "sqlsrv:Server =$server; database = ;", $uid, $pwd );
|
||||
echo "dsn with no value specified and ends with semicolon OK\n";
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
--TEST--
|
||||
direct execution of an invalid query
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb ", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:Server=$server; database = $databaseName ", $uid, $pwd);
|
||||
|
||||
$conn->exec("IF OBJECT_ID('table1', 'U') IS NOT NULL DROP TABLE table1");
|
||||
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
--TEST--
|
||||
fetch columns using fetch mode and different ways of binding columns
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function FetchMode_BoundMixed()
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
include("MsSetup.inc");
|
||||
|
||||
set_time_limit(0);
|
||||
$database = "tempdb";
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_tinyint] tinyint, [c3_smallint] smallint, [c4_bigint] bigint, [c5_bit] bit, [c6_float] float, [c7_real] real, [c8_decimal] decimal(28,4), [c9_numeric] numeric(32,4), [c10_money] money, [c11_smallmoney] smallmoney, [c12_char] char(512), [c13_varchar] varchar(512), [c14_varchar_max] varchar(max), [c15_nchar] nchar(512), [c16_nvarchar] nvarchar(512), [c17_nvarchar_max] nvarchar(max), [c18_text] text, [c19_ntext] ntext, [c20_binary] binary(512), [c21_varbinary] varbinary(512), [c22_varbinary_max] varbinary(max), [c23_image] image, [c24_uniqueidentifier] uniqueidentifier, [c25_datetime] datetime, [c26_smalldatetime] smalldatetime, [c27_timestamp] timestamp, [c28_xml] xml, [c29_time] time, [c30_date] date, [c31_datetime2] datetime2, [c32_datetimeoffset] datetimeoffset)");
|
||||
|
||||
|
@ -64,6 +63,8 @@ function FetchMode_BoundMixed()
|
|||
|
||||
$numFields = $stmt->columnCount();
|
||||
|
||||
include("pdo_tools.inc");
|
||||
|
||||
$i = 0;
|
||||
while ($row = $stmt->fetch(PDO::FETCH_BOUND))
|
||||
{
|
||||
|
@ -101,6 +102,7 @@ function GetQuery($tableName, $index)
|
|||
function Repro()
|
||||
{
|
||||
StartTest("pdo_fetch_bindcolumn_fetchmode");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
FetchMode_BoundMixed();
|
||||
|
@ -118,11 +120,10 @@ Repro();
|
|||
?>
|
||||
--EXPECT--
|
||||
|
||||
|
||||
...Starting 'pdo_fetch_bindcolumn_fetchmode' test...
|
||||
Starting test...
|
||||
Comparing data in row 1
|
||||
Comparing data in row 2
|
||||
|
||||
Done
|
||||
...Test 'pdo_fetch_bindcolumn_fetchmode' completed successfully.
|
||||
Test "pdo_fetch_bindcolumn_fetchmode" completed successfully.
|
||||
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
--TEST--
|
||||
fetch columns using fetch mode
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function FetchMode_GetAllColumnsEx()
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
include("MsSetup.inc");
|
||||
|
||||
set_time_limit(0);
|
||||
$database = "tempdb";
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_tinyint] tinyint, [c3_smallint] smallint, [c4_bigint] bigint, [c5_bit] bit, [c6_float] float, [c7_real] real, [c8_decimal] decimal(28,4), [c9_numeric] numeric(32,4), [c10_money] money, [c11_smallmoney] smallmoney, [c12_char] char(512), [c13_varchar] varchar(512), [c14_varchar_max] varchar(max), [c15_nchar] nchar(512), [c16_nvarchar] nvarchar(512), [c17_nvarchar_max] nvarchar(max), [c18_text] text, [c19_ntext] ntext, [c20_binary] binary(512), [c21_varbinary] varbinary(512), [c22_varbinary_max] varbinary(max), [c23_image] image, [c24_uniqueidentifier] uniqueidentifier, [c25_datetime] datetime, [c26_smalldatetime] smalldatetime, [c27_timestamp] timestamp, [c28_xml] xml, [c29_time] time, [c30_date] date, [c31_datetime2] datetime2, [c32_datetimeoffset] datetimeoffset)");
|
||||
|
||||
|
@ -32,6 +31,7 @@ function FetchMode_GetAllColumnsEx()
|
|||
$meta = $stmt->getColumnMeta(0);
|
||||
$colName = $meta['name'];
|
||||
|
||||
include("pdo_tools.inc");
|
||||
// Fetching with fetch mode PDO::FETCH_ASSOC
|
||||
echo "\nComparing data in column 0 and rows \n";
|
||||
for ($i = 1; $i <= $numRows; $i++)
|
||||
|
@ -556,9 +556,10 @@ function GetQuery($tableName, $index)
|
|||
return $query;
|
||||
}
|
||||
|
||||
function Repro()
|
||||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_fetch_columns_fetchmode");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
FetchMode_GetAllColumnsEx();
|
||||
|
@ -571,12 +572,12 @@ function Repro()
|
|||
EndTest("pdo_fetch_columns_fetchmode");
|
||||
}
|
||||
|
||||
Repro();
|
||||
RunTest();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_fetch_columns_fetchmode' test...
|
||||
Starting test...
|
||||
|
||||
Comparing data in column 0 and rows
|
||||
1 2
|
||||
|
@ -643,4 +644,4 @@ Comparing data in column 30 and rows
|
|||
Comparing data in column 31 and rows
|
||||
1 2
|
||||
Done
|
||||
...Test 'pdo_fetch_columns_fetchmode' completed successfully.
|
||||
Test "pdo_fetch_columns_fetchmode" completed successfully.
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
--TEST--
|
||||
Test transactions commit, rollback and aborting in between
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function ComplexTransaction($conn, $tableName)
|
||||
{
|
||||
|
@ -102,16 +104,16 @@ function FetchData($stmt, $tableName, $numRows, $fetchMode = false)
|
|||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_fetch_complex_transactions");
|
||||
echo "\nTest begins...\n";
|
||||
try
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
include("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$conn2 = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn2 = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
$conn2->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$tableName = GetTempTableName('testTransaction', false);
|
||||
|
@ -142,7 +144,7 @@ RunTest();
|
|||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_fetch_complex_transactions' test...
|
||||
Test begins...
|
||||
Number of rows fetched: 10
|
||||
Committed deleting 3 rows
|
||||
Number of rows fetched: 7
|
||||
|
@ -156,4 +158,4 @@ Deletion aborted
|
|||
Number of rows fetched: 4
|
||||
|
||||
Done
|
||||
...Test 'pdo_fetch_complex_transactions' completed successfully.
|
||||
Test "pdo_fetch_complex_transactions" completed successfully.
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a varbinary column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 'asdgasdgasdgsadg';
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a varchar column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = "eight";
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a datetime column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = '2012-06-18 10:34:09';
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a decimal column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890.1234;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a decimal column with the column bound an
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890.1234;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ function FlatsAreEqual($a, $b, $epsilon = 3.9265E-6)
|
|||
{
|
||||
return (abs($a - $b) < $epsilon);
|
||||
}
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890.1234;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ function FlatsAreEqual($a, $b, $epsilon = 3.9265E-6)
|
|||
{
|
||||
return (abs($a - $b) < $epsilon);
|
||||
}
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890.1234;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a int column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a int column with the column bound and sp
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$sample = 1234567890;
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a money column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890.1234;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a money column with the column bound and
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$sample = 1234567890.1234;
|
||||
|
|
|
@ -7,8 +7,8 @@ Uses buffered cursor to fetch from float, int, and decimal columns that have pos
|
|||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = 1234567890.1234;
|
||||
$sample1 = -1234567890.1234;
|
||||
|
|
|
@ -7,8 +7,8 @@ prepare with cursor buffered and fetch various columns with the column bound and
|
|||
|
||||
function test()
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$decimal = -2345209.3103;
|
||||
|
|
|
@ -4,8 +4,8 @@ prepare with cursor buffered and fetch a nvarchar column
|
|||
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$sample = "가각";
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
--TEST--
|
||||
Test with cursor scroll and select different rows in some random order
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function Cursor_ForwardOnly($conn, $tableName)
|
||||
{
|
||||
|
@ -144,13 +146,13 @@ function GetAbsoluteRow($stmt, $offset)
|
|||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_fetch_cursor_scroll_random");
|
||||
echo "\nTest begins...\n";
|
||||
try
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
include("MsSetup.inc");
|
||||
|
||||
// Connect
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
|
||||
$tableName = GetTempTableName();
|
||||
|
@ -173,7 +175,7 @@ RunTest();
|
|||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_fetch_cursor_scroll_random' test...
|
||||
Test begins...
|
||||
1
|
||||
2
|
||||
3
|
||||
|
@ -216,4 +218,4 @@ last row: 10
|
|||
|
||||
row 1 from the current row:
|
||||
Done
|
||||
...Test 'pdo_fetch_cursor_scroll_random' completed successfully.
|
||||
Test "pdo_fetch_cursor_scroll_random" completed successfully.
|
|
@ -1,11 +1,11 @@
|
|||
--TEST--
|
||||
fetch columns using fetch mode and different ways of binding columns
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
class PdoTestClass
|
||||
{
|
||||
function __construct ()
|
||||
|
@ -24,13 +24,12 @@ class PdoTestClass2
|
|||
|
||||
function FetchInto_Query_Args()
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
include("MsSetup.inc");
|
||||
|
||||
set_time_limit(0);
|
||||
$database = "tempdb";
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_tinyint] tinyint, [c3_smallint] smallint, [c4_bigint] bigint, [c5_bit] bit, [c6_float] float, [c7_real] real, [c8_decimal] decimal(28,4), [c9_numeric] numeric(32,4), [c10_money] money, [c11_smallmoney] smallmoney, [c12_char] char(512), [c13_varchar] varchar(512), [c14_varchar_max] varchar(max), [c15_nchar] nchar(512), [c16_nvarchar] nvarchar(512), [c17_nvarchar_max] nvarchar(max), [c18_text] text, [c19_ntext] ntext, [c20_binary] binary(512), [c21_varbinary] varbinary(512), [c22_varbinary_max] varbinary(max), [c23_image] image, [c24_uniqueidentifier] uniqueidentifier, [c25_datetime] datetime, [c26_smalldatetime] smalldatetime, [c27_timestamp] timestamp, [c28_xml] xml, [c29_time] time, [c30_date] date, [c31_datetime2] datetime2, [c32_datetimeoffset] datetimeoffset)");
|
||||
|
||||
|
@ -60,6 +59,7 @@ function FetchInto_Query_Args()
|
|||
|
||||
function VerifyResults($stmt1, $stmt2, $tableName)
|
||||
{
|
||||
include 'pdo_tools.inc';
|
||||
$numFields = $stmt1->columnCount();
|
||||
|
||||
$i = 0;
|
||||
|
@ -106,6 +106,7 @@ function GetQuery($tableName, $index)
|
|||
function Repro()
|
||||
{
|
||||
StartTest("pdo_fetch_fetchinto_query_args");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
FetchInto_Query_Args();
|
||||
|
@ -123,12 +124,12 @@ Repro();
|
|||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_fetch_fetchinto_query_args' test...
|
||||
Starting test...
|
||||
Constructor called with 0 arguments
|
||||
Constructor called with 2 arguments
|
||||
Comparing data in row 1
|
||||
Comparing data in row 2
|
||||
|
||||
Done
|
||||
...Test 'pdo_fetch_fetchinto_query_args' completed successfully.
|
||||
Test "pdo_fetch_fetchinto_query_args" completed successfully.
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
Test client info by calling PDO::getAttribute with PDO::ATTR_CLIENT_VERSION
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName", "$username", "$password" );
|
||||
$conn = new PDO( "sqlsrv:server=$server", "$uid", "$pwd" );
|
||||
|
||||
// An example using PDO::ATTR_CLIENT_VERSION
|
||||
print_r($conn->getAttribute( PDO::ATTR_CLIENT_VERSION ));
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
--TEST--
|
||||
Test getting invalid attributes
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$databaseName = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
$conn = new PDO( $dsn, $uid, $pwd, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
|
||||
@$conn->getAttribute( PDO::ATTR_FETCH_TABLE_NAMES );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
|
@ -26,7 +26,7 @@ try{
|
|||
echo "\n";
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
exit;
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
--TEST--
|
||||
Test PDO::setAttribute() and PDO::getAttribute() methods.
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
// A custom PDO statement class to test PDO::ATTR_STATEMENT_CLASS
|
||||
class CustomPDOStatement extends PDOStatement
|
||||
{
|
||||
|
@ -57,8 +57,7 @@ function set_get_attr($testName, $conn, $attr, $val)
|
|||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO("sqlsrv:Server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO("sqlsrv:Server=$server;database=$databaseName", $uid, $pwd);
|
||||
$values = array ( "PDO::ATTR_ERRMODE" => 2,
|
||||
"PDO::ATTR_SERVER_VERSION" => "whatever",
|
||||
"PDO::ATTR_DRIVER_NAME" => "whatever",
|
||||
|
@ -154,11 +153,11 @@ Set Result PDO::ATTR_SERVER_INFO :
|
|||
SQLSTATE\[IMSSP\]: A read-only attribute was designated on the PDO object.
|
||||
Get Result PDO::ATTR_SERVER_INFO :
|
||||
array\(3\) {
|
||||
\["CurrentDatabase"\]=>
|
||||
\["CurrentdatabaseName"\]=>
|
||||
string\([0-9]*\) ".*"
|
||||
\["SQLServerVersion"\]=>
|
||||
string\(10\) "[0-9]{2}.[0-9]{2}.[0-9]{4}"
|
||||
\["SQLServerName"\]=>
|
||||
\["SQLserver"\]=>
|
||||
string\([0-9]*\) ".*"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
--TEST--
|
||||
Test PDO::__Construct with invalid connection option
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName;" .
|
||||
"Database = $database;" .
|
||||
$databaseName = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $server;" .
|
||||
"database = $databaseName;" .
|
||||
"InvalidKey = true;"
|
||||
;
|
||||
$conn = new PDO( $dsn, $username, $password);
|
||||
$conn = new PDO( $dsn, $uid, $pwd);
|
||||
|
||||
echo "Test Successful";
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
--TEST--
|
||||
Test various Katmai types, like geography, geometry, hierarchy, sparse, etc. and fetch them back as strings
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function Katmai_Basic_Types($conn)
|
||||
{
|
||||
|
@ -102,14 +104,13 @@ function Katmai_SparseNumeric($conn)
|
|||
function Repro()
|
||||
{
|
||||
StartTest("pdo_katmai_special_types");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
|
||||
include("MsSetup.inc");
|
||||
set_time_limit(0);
|
||||
$database = "tempdb";
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
Katmai_Basic_Types($conn);
|
||||
Katmai_SparseChar($conn);
|
||||
|
@ -131,7 +132,7 @@ Repro();
|
|||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_katmai_special_types' test...
|
||||
Starting test...
|
||||
|
||||
Showing results of Katmai basic fields
|
||||
string(16) "03:32:25.5643401"
|
||||
|
@ -157,4 +158,4 @@ string(6) "1.0000"
|
|||
string(6) "1.0000"
|
||||
|
||||
Done
|
||||
...Test 'pdo_katmai_special_types' completed successfully.
|
||||
Test "pdo_katmai_special_types" completed successfully.
|
|
@ -1,42 +1,36 @@
|
|||
--TEST--
|
||||
Test the PDO::lastInsertId() method.
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO("sqlsrv:Server=$serverName;Database=$database", $username, $password);
|
||||
$databaseName = "tempdb";
|
||||
$conn = new PDO("sqlsrv:Server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$conn->exec("IF OBJECT_ID('tmp_table1', 'U') IS NOT NULL DROP TABLE [tmp_table1]");
|
||||
$conn->exec("IF OBJECT_ID('tmp_table2', 'U') IS NOT NULL DROP TABLE [tmp_table2]");
|
||||
$conn->exec("IF OBJECT_ID('tmp_table3', 'U') IS NOT NULL DROP TABLE [tmp_table3]");
|
||||
$conn->exec('CREATE TABLE tmp_table1(id INT IDENTITY(100,2), val INT)');
|
||||
$conn->exec('CREATE TABLE tmp_table2(id INT IDENTITY(200,2), val INT)');
|
||||
$conn->exec('CREATE TABLE tmp_table3(id INT, val INT)');
|
||||
// create temporary tables
|
||||
$conn->exec('CREATE TABLE #tmp_table1(id INT IDENTITY(100,2), val INT)');
|
||||
$conn->exec('CREATE TABLE #tmp_table2(id INT IDENTITY(200,2), val INT)');
|
||||
$conn->exec('CREATE TABLE #tmp_table3(id INT, val INT)');
|
||||
|
||||
$conn->exec('INSERT INTO tmp_table1 VALUES(1)');
|
||||
$conn->exec('INSERT INTO tmp_table2 VALUES(2)');
|
||||
$conn->exec('INSERT INTO #tmp_table1 VALUES(1)');
|
||||
$conn->exec('INSERT INTO #tmp_table2 VALUES(2)');
|
||||
$id = $conn->lastInsertId();
|
||||
var_dump($id);
|
||||
|
||||
$conn->exec('INSERT INTO tmp_table2 VALUES(3)');
|
||||
$conn->exec('INSERT INTO tmp_table1 VALUES(4)');
|
||||
$conn->exec('INSERT INTO #tmp_table2 VALUES(3)');
|
||||
$conn->exec('INSERT INTO #tmp_table1 VALUES(4)');
|
||||
$id = $conn->lastInsertId();
|
||||
var_dump($id);
|
||||
|
||||
// Should return empty string as the table does not have an IDENTITY column.
|
||||
$conn->exec('INSERT INTO tmp_table3 VALUES(1,1)');
|
||||
$conn->exec('INSERT INTO #tmp_table3 VALUES(1,1)');
|
||||
$id = $conn->lastInsertId();
|
||||
var_dump($id);
|
||||
|
||||
// clean up
|
||||
$conn->exec('DROP TABLE tmp_table1');
|
||||
$conn->exec('DROP TABLE tmp_table2');
|
||||
$conn->exec('DROP TABLE tmp_table3');
|
||||
}
|
||||
|
||||
catch( PDOException $e ) {
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
--TEST--
|
||||
fetch multiple result sets with MARS on and then off
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function NestedQuery_Mars($on)
|
||||
{
|
||||
require("autonomous_setup.php");
|
||||
require("MsSetup.inc");
|
||||
|
||||
$database = "tempdb";
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database;MultipleActiveResultSets=$on", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName;MultipleActiveResultSets=$on", $uid, $pwd);
|
||||
$conn->SetAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_varchar] varchar(20))");
|
||||
|
@ -56,9 +55,10 @@ function NestedQuery_Mars($on)
|
|||
$conn = null;
|
||||
}
|
||||
|
||||
function Repro()
|
||||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_nested_query_mars");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
NestedQuery_Mars(true);
|
||||
|
@ -72,12 +72,12 @@ function Repro()
|
|||
EndTest("pdo_nested_query_mars");
|
||||
}
|
||||
|
||||
Repro();
|
||||
RunTest();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_nested_query_mars' test...
|
||||
Starting test...
|
||||
|
||||
Number of columns in First set: 2
|
||||
Array
|
||||
|
@ -105,4 +105,4 @@ stdClass Object
|
|||
)
|
||||
SQLSTATE[IMSSP]: The connection cannot process this operation because there is a statement with pending results. To make the connection available for other queries, either fetch all results or cancel or free the statement. For more information, see the product documentation about the MultipleActiveResultSets connection option.
|
||||
Done
|
||||
...Test 'pdo_nested_query_mars' completed successfully.
|
||||
Test "pdo_nested_query_mars" completed successfully.
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
--TEST--
|
||||
call stored procedures with inputs of ten different datatypes to get outputs of various types
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
try
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
require_once("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$proc_scale = GetTempProcName( 'scale_proc' );
|
||||
$proc_no_scale = GetTempProcName( 'noScale_proc' );
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
--TEST--
|
||||
Test PDO::prepare by passing in invalid cursor value
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:Server = $serverName; Database = $database", $username, $password);
|
||||
$databaseName = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:Server = $server; database = $databaseName", $uid, $pwd);
|
||||
|
||||
// PDO::CURSOR_FWDONLY should not be quoted
|
||||
$stmt1 = $conn->prepare( "SELECT 1", array( PDO::ATTR_CURSOR => "PDO::CURSOR_FWDONLY" ));
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
--TEST--
|
||||
Test PDO::prepare by passing in invalid encoding values
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:Server = $serverName; Database = $database", $username, $password);
|
||||
$databaseName = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:Server = $server; database = $databaseName", $uid, $pwd);
|
||||
|
||||
// PDO::SQLSRV_ENCODING_SYSTEM should not be quoted
|
||||
$stmt1 = $conn->prepare( "SELECT 1", array( PDO::SQLSRV_ATTR_ENCODING => "PDO::SQLSRV_ENCODING_SYSTEM" ));
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
--TEST--
|
||||
Test PDO::prepare by passing in a string key
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$databaseName = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
||||
$attr = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
|
||||
$conn = new PDO( $dsn, $username, $password, $attr);
|
||||
$conn = new PDO( $dsn, $uid, $pwd, $attr);
|
||||
|
||||
$stmt = $conn->prepare( "SELECT 1", array( "PDO::ATTR_CURSOR" => PDO::CURSOR_FWDONLY ));
|
||||
|
||||
|
||||
echo "Test Successful";
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
--TEST--
|
||||
Test PDO::prepare by passing in invalid scrollable type value
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$database = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:Server = $serverName; Database = $database", $username, $password);
|
||||
//$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$databaseName = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:Server = $server; database = $databaseName", $uid, $pwd);
|
||||
|
||||
// PDO::SQLSRV_CURSOR_BUFFERED should not be quoted
|
||||
$stmt1 = $conn->prepare( "SELECT 1", array( PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => "PDO::SQLSRV_CURSOR_BUFFERED" ));
|
||||
|
@ -19,15 +18,14 @@ try
|
|||
// if ATTR_CURSOR is FWDONLY, cannot set SCROLL_TYPE
|
||||
$stmt2 = $conn->prepare( "SELECT 2", array( PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED ));
|
||||
|
||||
if ( $stmt1 || $stmt2 )
|
||||
{
|
||||
if ( $stmt1 || $stmt2 ){
|
||||
echo "Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE should return false.\n";
|
||||
} else {
|
||||
echo "Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE return false.\n";
|
||||
}
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
var_dump( $e->errorInfo );
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -1,38 +1,36 @@
|
|||
--TEST--
|
||||
Test PDO::prepare by passing in attributes
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
class CustomPDOStatement extends PDOStatement
|
||||
{
|
||||
protected function __construct() {
|
||||
}
|
||||
}
|
||||
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$databaseName = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
||||
$prep_attr = array(PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_UTF8,
|
||||
PDO::ATTR_STATEMENT_CLASS => array('CustomPDOStatement', array()),
|
||||
PDO::SQLSRV_ATTR_DIRECT_QUERY => true,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true
|
||||
);
|
||||
$conn = new PDO( $dsn, $username, $password);
|
||||
$conn = new PDO( $dsn, $uid, $pwd);
|
||||
|
||||
$stmt = $conn->prepare( "SELECT 1", $prep_attr );
|
||||
|
||||
echo "Test Successful";
|
||||
}
|
||||
catch( PDOException $e ) {
|
||||
var_dump( $e->errorInfo );
|
||||
exit;
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
--TEST--
|
||||
test query time out at the connection level and statement level
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function QueryTimeout($connLevel)
|
||||
{
|
||||
require("autonomous_setup.php");
|
||||
require("MsSetup.inc");
|
||||
|
||||
$database = "tempdb";
|
||||
$tableName = GetTempTableName();
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_varchar] varchar(25))");
|
||||
|
||||
|
@ -47,9 +46,10 @@ function QueryTimeout($connLevel)
|
|||
$conn = null;
|
||||
}
|
||||
|
||||
function Repro()
|
||||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_query_timeout");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
QueryTimeout(true);
|
||||
|
@ -63,12 +63,12 @@ function Repro()
|
|||
EndTest("pdo_query_timeout");
|
||||
}
|
||||
|
||||
Repro();
|
||||
RunTest();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_query_timeout' test...
|
||||
Starting test...
|
||||
Setting query timeout as an attribute in connection
|
||||
array(3) {
|
||||
[0]=>
|
||||
|
@ -89,4 +89,4 @@ array(3) {
|
|||
}
|
||||
|
||||
Done
|
||||
...Test 'pdo_query_timeout' completed successfully.
|
||||
Test "pdo_query_timeout" completed successfully.
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
--TEST--
|
||||
Test setting invalid value or key in connection attributes
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$databaseName = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
$conn = new PDO( $dsn, $uid, $pwd, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
|
||||
// Negative value for query timeout: should raise error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_QUERY_TIMEOUT, -1 );
|
||||
|
@ -23,7 +23,7 @@ try{
|
|||
print_r (($conn->errorInfo())[2]);
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
exit;
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
--TEST--
|
||||
Test setting invalid encoding attributes
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
$conn = new PDO( $dsn, $uid, $pwd, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
|
||||
// valid option: should have no error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_DEFAULT );
|
||||
|
@ -29,7 +28,7 @@ try{
|
|||
echo "\n";
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
exit;
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
--TEST--
|
||||
test rowCount() with different querying method and test nextRowset() with different fetch
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function RowCount_Query($exec)
|
||||
{
|
||||
require("autonomous_setup.php");
|
||||
require("MsSetup.inc");
|
||||
|
||||
$database = "tempdb";
|
||||
$tableName = GetTempTableName();
|
||||
$tableName = GetTempTableName('testRowCount');
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_real] real)");
|
||||
|
||||
|
@ -154,9 +152,10 @@ function DeleteData($conn, $tableName, $exec)
|
|||
$stmt = null;
|
||||
}
|
||||
|
||||
function Repro()
|
||||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_statement_rowcount_query");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
RowCount_Query(true);
|
||||
|
@ -170,12 +169,12 @@ function Repro()
|
|||
EndTest("pdo_statement_rowcount_query");
|
||||
}
|
||||
|
||||
Repro();
|
||||
RunTest();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_statement_rowcount_query' test...
|
||||
Starting test...
|
||||
|
||||
Done
|
||||
...Test 'pdo_statement_rowcount_query' completed successfully.
|
||||
Test "pdo_statement_rowcount_query" completed successfully.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
--TEST--
|
||||
call stored procedures with inputs of ten different datatypes to get outputs of various types
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function ProcFetch_BigInt($conn)
|
||||
{
|
||||
|
@ -277,15 +277,15 @@ function ProcFetch_TinyInt($conn)
|
|||
$stmt = null;
|
||||
}
|
||||
|
||||
function Repro()
|
||||
function RunTest()
|
||||
{
|
||||
set_time_limit(0);
|
||||
StartTest("pdo_stored_proc_fetch_datatypes");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
$database = "tempdb";
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
include("MsSetup.inc");
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
ProcFetch_BigInt($conn);
|
||||
ProcFetch_Decimal($conn);
|
||||
|
@ -308,13 +308,13 @@ function Repro()
|
|||
EndTest("pdo_stored_proc_fetch_datatypes");
|
||||
}
|
||||
|
||||
Repro();
|
||||
RunTest();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_stored_proc_fetch_datatypes' test...
|
||||
Starting test...
|
||||
|
||||
Done
|
||||
...Test 'pdo_stored_proc_fetch_datatypes' completed successfully.
|
||||
Test "pdo_stored_proc_fetch_datatypes" completed successfully.
|
||||
|
||||
|
|
|
@ -3,56 +3,6 @@
|
|||
define("_EPSILON", 0.00001);
|
||||
define("_CHUNK_SIZE", 8192);
|
||||
|
||||
function StartTest($testName)
|
||||
{
|
||||
echo "\n...Starting '$testName' test...\n";
|
||||
if (!extension_loaded("pdo_sqlsrv"))
|
||||
{
|
||||
die("pdo_sqlsrv driver cannot be loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
function EndTest($testName)
|
||||
{
|
||||
echo "...Test '$testName' completed successfully.\n";
|
||||
}
|
||||
|
||||
function GetTempTableName($table = '', $temporary = true)
|
||||
{
|
||||
// A temporary table name with the '#' prefix will be automatically
|
||||
// dropped once the connection is closed. Otherwise, the caller
|
||||
// should take care of dropping the temp table afterwards.
|
||||
|
||||
$timestamp = round(microtime(true)*1000);
|
||||
|
||||
$prefix = '';
|
||||
if ($temporary)
|
||||
$prefix = '#';
|
||||
|
||||
if (strlen($table) == 0)
|
||||
$table = 'php_test_table';
|
||||
|
||||
return $prefix . $table . '_' . $timestamp;
|
||||
}
|
||||
|
||||
function GetTempProcName($proc = '', $temporary = true)
|
||||
{
|
||||
// A temporary stored procedure name with the '#' prefix will be
|
||||
// automatically dropped once the connection is closed. Otherwise,
|
||||
// the caller should take care of dropping the temp procedure afterwards.
|
||||
|
||||
$timestamp = round(microtime(true)*1000);
|
||||
|
||||
$prefix = '';
|
||||
if ($temporary)
|
||||
$prefix = '#';
|
||||
|
||||
if (strlen($proc) == 0)
|
||||
$proc = 'php_test_proc';
|
||||
|
||||
return $prefix . $proc . '_' . $timestamp;
|
||||
}
|
||||
|
||||
function CompareNumericData($actual, $expected)
|
||||
{
|
||||
if (! is_numeric($actual))
|
||||
|
@ -90,7 +40,7 @@ function CheckData($colType, $actual, $expected)
|
|||
{
|
||||
$success = true;
|
||||
|
||||
if (IsBinary($colType))
|
||||
if (IsBinaryType($colType))
|
||||
{
|
||||
$actual = bin2hex($actual);
|
||||
}
|
||||
|
@ -107,7 +57,7 @@ function CheckData($colType, $actual, $expected)
|
|||
$actual = trim($actual);
|
||||
$len = strlen($expected);
|
||||
|
||||
if (IsDateTime($colType))
|
||||
if (IsDateTimeType($colType))
|
||||
{
|
||||
if ($colType != 'time')
|
||||
$len = min(strlen("YYYY-MM-DD HH:mm:ss"), $len);
|
||||
|
@ -153,9 +103,9 @@ function CompareData($stmt, $rowIndex, $colIndex, $actual, $expected)
|
|||
$colType = $meta['sqlsrv:decl_type'];
|
||||
$colName = $meta['name'];
|
||||
|
||||
if (! IsUpdatable($colName))
|
||||
if (! IsColumnUpdatable($colName))
|
||||
{
|
||||
return true; // do nothing for non-IsUpdatable fields
|
||||
return true; // do nothing for non-IsColumnUpdatable fields
|
||||
}
|
||||
|
||||
return CompareDataValue($colType, $rowIndex, $colName, $actual, $expected);
|
||||
|
@ -208,7 +158,7 @@ function GetColumnData($stmt, $query, $rowIndex, $colIndex)
|
|||
$type = $meta['sqlsrv:decl_type'];
|
||||
$name = $meta['name'];
|
||||
|
||||
if (!IsUpdatable($name))
|
||||
if (!IsColumnUpdatable($name))
|
||||
{
|
||||
$skipCount++;
|
||||
}
|
||||
|
@ -216,7 +166,7 @@ function GetColumnData($stmt, $query, $rowIndex, $colIndex)
|
|||
{
|
||||
if ($j == $colIndex)
|
||||
{
|
||||
$data = GetInsertData($query, $type, $rowIndex, $j + 1, $skipCount);
|
||||
$data = GetInsertDataByType($query, $type, $rowIndex, $j + 1, $skipCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -237,14 +187,14 @@ function InsertDataToArray($stmt, $query, $numFields, $rowIndex)
|
|||
$name = $meta['name'];
|
||||
|
||||
$colIndex = $j + 1;
|
||||
if (!IsUpdatable($name))
|
||||
if (!IsColumnUpdatable($name))
|
||||
{
|
||||
$skipCount++;
|
||||
array_push($dataArray, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = GetInsertData($query, $type, $rowIndex, $colIndex, $skipCount);
|
||||
$data = GetInsertDataByType($query, $type, $rowIndex, $colIndex, $skipCount);
|
||||
array_push($dataArray, $data);
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +202,7 @@ function InsertDataToArray($stmt, $query, $numFields, $rowIndex)
|
|||
return $dataArray;
|
||||
}
|
||||
|
||||
function GetInsertData($query, $colType, $rowIndex, $colIndex, $skip)
|
||||
function GetInsertDataByType($query, $colType, $rowIndex, $colIndex, $skip)
|
||||
{
|
||||
$data = strstr($query, "((");
|
||||
$pos = 1;
|
||||
|
@ -287,7 +237,7 @@ function GetInsertData($query, $colType, $rowIndex, $colIndex, $skip)
|
|||
{
|
||||
$tmp = "";
|
||||
}
|
||||
else if (IsXml($colType))
|
||||
else if (IsXmlType($colType))
|
||||
{
|
||||
$str = ">')";
|
||||
$pos = strpos($data, $str);
|
||||
|
@ -300,11 +250,11 @@ function GetInsertData($query, $colType, $rowIndex, $colIndex, $skip)
|
|||
{ // N'data'
|
||||
$data = substr($data, 2, strlen($data) - 3);
|
||||
}
|
||||
else if (IsLiteral($colType))
|
||||
else if (IsLiteralType($colType))
|
||||
{ // 'data'
|
||||
$data = substr($data, 1, strlen($data) - 2);
|
||||
}
|
||||
else if (IsBinary($colType))
|
||||
else if (IsBinaryType($colType))
|
||||
{ // 0xdata
|
||||
$data = substr($data, 2);
|
||||
}
|
||||
|
@ -355,7 +305,7 @@ function CompareBinaryStream($inputFile, $actual)
|
|||
return $matched;
|
||||
}
|
||||
|
||||
function IsUpdatable($colName)
|
||||
function IsColumnUpdatable($colName)
|
||||
{
|
||||
$pos = strpos($colName, "_");
|
||||
$type = substr($colName, $pos + 1);
|
||||
|
@ -365,7 +315,7 @@ function IsUpdatable($colName)
|
|||
|
||||
function IsDataUnicode($colType, $data)
|
||||
{
|
||||
if (IsUnicode($colType))
|
||||
if (IsUnicodeType($colType))
|
||||
return true;
|
||||
|
||||
// This input string may be an XML string in unicode (i.e. // N'<xmldata>...</xmldata>')
|
||||
|
@ -382,7 +332,7 @@ function IsDataUnicode($colType, $data)
|
|||
return false;
|
||||
}
|
||||
|
||||
function IsUnicode($type)
|
||||
function IsUnicodeType($type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
|
@ -396,12 +346,12 @@ function IsUnicode($type)
|
|||
return (false);
|
||||
}
|
||||
|
||||
function IsXml($type)
|
||||
function IsXmlType($type)
|
||||
{
|
||||
return ($type == 'xml');
|
||||
}
|
||||
|
||||
function IsBinary($type)
|
||||
function IsBinaryType($type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
|
@ -415,7 +365,7 @@ function IsBinary($type)
|
|||
return (false);
|
||||
}
|
||||
|
||||
function IsDateTime($type)
|
||||
function IsDateTimeType($type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
|
@ -432,7 +382,7 @@ function IsDateTime($type)
|
|||
return (false);
|
||||
}
|
||||
|
||||
function IsLiteral($type)
|
||||
function IsLiteralType($type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
--TEST--
|
||||
test transaction rollback and commit
|
||||
--DESCRIPTION--
|
||||
starts a transaction, delete rows and rollback the transaction; starts a transaction, delete rows and commit
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:Server=$server; database = $databaseName", $uid, $pwd);
|
||||
|
||||
$conn->exec("IF OBJECT_ID('Table1', 'U') IS NOT NULL DROP TABLE Table1");
|
||||
$conn->exec("CREATE TABLE Table1(col1 CHARACTER(1), col2 CHARACTER(1))");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
--TEST--
|
||||
call a stored procedure with unicode input to get output back as unicode; also test with xml data
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include 'pdo_tools.inc';
|
||||
include 'MsCommon.inc';
|
||||
|
||||
function StoredProc_Xml($conn)
|
||||
{
|
||||
|
@ -64,17 +64,16 @@ function StoredProc_Unicode($conn)
|
|||
$stmt = null;
|
||||
}
|
||||
|
||||
function Repro()
|
||||
function RunTest()
|
||||
{
|
||||
StartTest("pdo_utf8_stored_proc_unicode_chars");
|
||||
echo "\nStarting test...\n";
|
||||
try
|
||||
{
|
||||
require_once("autonomous_setup.php");
|
||||
|
||||
include("MsSetup.inc");
|
||||
set_time_limit(0);
|
||||
$database = "tempdb";
|
||||
|
||||
$conn = new PDO( "sqlsrv:server=$serverName;Database=$database", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
||||
|
||||
StoredProc_Xml($conn);
|
||||
StoredProc_Surrogate($conn);
|
||||
|
@ -90,16 +89,16 @@ function Repro()
|
|||
EndTest("pdo_utf8_stored_proc_unicode_chars");
|
||||
}
|
||||
|
||||
Repro();
|
||||
RunTest();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
|
||||
...Starting 'pdo_utf8_stored_proc_unicode_chars' test...
|
||||
Starting test...
|
||||
string(47) "<XmlTestData>Je préfère l'été</XmlTestData>"
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
Done
|
||||
...Test 'pdo_utf8_stored_proc_unicode_chars' completed successfully.
|
||||
Test "pdo_utf8_stored_proc_unicode_chars" completed successfully.
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
--TEST--
|
||||
Test warnings on connection and statement levels
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
try{
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb ", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:Server=$server; database = $databaseName ", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
|
||||
|
||||
// raise a warning in connection
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
--TEST--
|
||||
Test the bindColumn method using PDO::PARAM_NULL and PDO::PARAM_STMT
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb ", $username, $password);
|
||||
$conn = new PDO( "sqlsrv:Server=$server; database = $databaseName ", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$conn->exec("IF OBJECT_ID('table1', 'U') IS NOT NULL DROP TABLE table1");
|
||||
$conn->exec("CREATE TABLE table1(IntCol INT, CharCol NVARCHAR(20)) ");
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
--TEST--
|
||||
Test setting and getting various statement attributes.
|
||||
--SKIPIF--
|
||||
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
|
||||
function set_stmt_option($conn, $arr)
|
||||
{
|
||||
try {
|
||||
|
@ -125,7 +123,9 @@ function Test6($conn)
|
|||
|
||||
try
|
||||
{
|
||||
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb ", $username, $password);
|
||||
include("MsSetup.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:Server=$server; Database = $databaseName ", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||
$conn->exec("IF OBJECT_ID('temptb', 'U') IS NOT NULL DROP TABLE temptb");
|
||||
$conn->exec("CREATE TABLE temptb(id INT NOT NULL PRIMARY KEY, val VARCHAR(10)) ");
|
||||
|
|
4
test/pdo_sqlsrv/skipif.inc
Normal file
4
test/pdo_sqlsrv/skipif.inc
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv'))
|
||||
die("PDO driver cannot be loaded; skipping test.\n");
|
||||
?>
|
10
test/pdo_sqlsrv/skipif_azure.inc
Normal file
10
test/pdo_sqlsrv/skipif_azure.inc
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv'))
|
||||
die("PDO driver cannot be loaded; skipping test.\n");
|
||||
|
||||
include 'MsCommon.inc';
|
||||
if ( IsDaasMode() ) {
|
||||
die("skip test in Azure");
|
||||
}
|
||||
|
||||
?>
|
|
@ -3,7 +3,7 @@ Test the connection resiliency keywords
|
|||
--DESCRIPTION--
|
||||
Test the connection resiliency keywords ConnectRetryCount and ConnectRetryInterval and their ranges of acceptable values
|
||||
--SKIPIF--
|
||||
<?php if ( !( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' ) ) die( "Skip, not running on windows." ); ?>
|
||||
<?php if ( !( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' ) ) die( "Skip, test on windows only." ); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once( "MsSetup.inc" );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
--TEST--
|
||||
Create database that already exists
|
||||
--SKIPIF--
|
||||
<?php require('skipif_azure.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("MsCommon.inc");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
--TEST--
|
||||
Create database that already exists
|
||||
--SKIPIF--
|
||||
<?php require('skipif_azure.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("MsCommon.inc");
|
||||
|
|
Loading…
Reference in a new issue