Merge pull request #582 from v-kaywon/refactorPDOTests3
Refactor PDO tests with client buffer or table with all datatypes
This commit is contained in:
commit
07ac237def
|
@ -62,11 +62,11 @@ $pdoParamTypes = array(
|
||||||
|
|
||||||
// Checks if the current error is the incompatible types error
|
// Checks if the current error is the incompatible types error
|
||||||
// if so, state which sql type is incompatible with which data type
|
// if so, state which sql type is incompatible with which data type
|
||||||
function is_incompatible_types_error( $stmt, $dataType, $pdoParamType ) {
|
function isIncompatibleTypesError($stmt, $dataType, $pdoParamType)
|
||||||
if ( $stmt->errorInfo()[0] == "22018" )
|
{
|
||||||
|
if ($stmt->errorInfo()[0] == "22018") {
|
||||||
echo "PDO param type $pdoParamType is incompatible with encrypted $dataType\n";
|
echo "PDO param type $pdoParamType is incompatible with encrypted $dataType\n";
|
||||||
else
|
} else {
|
||||||
var_dump( $stmt->errorInfo() );
|
var_dump($stmt->errorInfo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -12,7 +12,6 @@
|
||||||
// looks like an additional file (in addition to pdo_test_base.inc) may be needed for these PHPTs
|
// looks like an additional file (in addition to pdo_test_base.inc) may be needed for these PHPTs
|
||||||
// to be runnable from the MSSQL teams' internal proprietary test running system
|
// to be runnable from the MSSQL teams' internal proprietary test running system
|
||||||
//
|
//
|
||||||
require 'MsData.inc';
|
|
||||||
|
|
||||||
function IsAEQualified($conn)
|
function IsAEQualified($conn)
|
||||||
{
|
{
|
||||||
|
@ -35,9 +34,7 @@ function connect($options=array())
|
||||||
require 'MsSetup.inc';
|
require 'MsSetup.inc';
|
||||||
$conn = new PDO( "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;" , $uid, $pwd, $options);
|
$conn = new PDO( "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;" , $uid, $pwd, $options);
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||||
create_and_insert_table1($conn);
|
return $conn;
|
||||||
create_and_insert_table2($conn);
|
|
||||||
return $conn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch( PDOException $e )
|
catch( PDOException $e )
|
||||||
|
@ -447,155 +444,6 @@ function is_col_enc()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create and insert
|
|
||||||
function create_and_insert_table1( $conn )
|
|
||||||
{
|
|
||||||
global $string_col, $date_col, $large_string_col, $xml_col, $binary_col, $int_col, $decimal_col, $guid_col, $null_col, $comma, $closing_brace, $table1;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$create_query =
|
|
||||||
|
|
||||||
"IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'" . $table1 . "') AND type in (N'U'))
|
|
||||||
DROP TABLE " . $table1 .
|
|
||||||
|
|
||||||
" CREATE TABLE [dbo].[" . $table1 . "](
|
|
||||||
[IntCol] [int] NULL,
|
|
||||||
[CharCol] [char](10) NULL,
|
|
||||||
[NCharCol] [nchar](10) NULL,
|
|
||||||
[DateTimeCol] [datetime] NULL,
|
|
||||||
[VarcharCol] [varchar](50) NULL,
|
|
||||||
[NVarCharCol] [nvarchar](50) NULL,
|
|
||||||
[FloatCol] [float] NULL,
|
|
||||||
[XmlCol] [xml] NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
";
|
|
||||||
|
|
||||||
$conn->query( $create_query );
|
|
||||||
|
|
||||||
for ($i = 0 ; $i <= 1; ++ $i)
|
|
||||||
{
|
|
||||||
$insert_query =
|
|
||||||
"INSERT INTO PDO_Types_1 VALUES (".
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
"Convert(datetime, ". $date_col[$i] . ")" . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$decimal_col[$i] . $comma .
|
|
||||||
$xml_col[$i] .
|
|
||||||
")";
|
|
||||||
|
|
||||||
$conn->query ( $insert_query );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception $e)
|
|
||||||
{
|
|
||||||
var_dump( $e);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_and_insert_table2( $conn )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//Timestamp is not present.
|
|
||||||
//VARIANT is not supported.
|
|
||||||
global $string_col, $date_col, $large_string_col, $xml_col, $binary_col, $int_col, $decimal_col, $guid_col, $null_col, $comma, $closing_brace, $table1, $table2;
|
|
||||||
|
|
||||||
$create_query =
|
|
||||||
"IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'".$table2."') AND type in (N'U')) DROP TABLE " . $table2 .
|
|
||||||
|
|
||||||
" CREATE TABLE " .$table2 . " (
|
|
||||||
[BigIntCol] [bigint] NULL,
|
|
||||||
[BinaryCol] [binary](5) NULL,
|
|
||||||
[BitCol] [bit] NULL,
|
|
||||||
[CharCol] [char](10) NULL,
|
|
||||||
[DateCol] [date] NULL,
|
|
||||||
[DateTimeCol] [datetime] NULL,
|
|
||||||
[DateTime2Col] [datetime2](7) NULL,
|
|
||||||
[DTOffsetCol] [datetimeoffset](7) NULL,
|
|
||||||
[DecimalCol] [decimal](18, 0) NULL,
|
|
||||||
[FloatCol] [float] NULL,
|
|
||||||
[ImageCol] [image] NULL,
|
|
||||||
[IntCol] [int] NULL,
|
|
||||||
[MoneyCol] [money] NULL,
|
|
||||||
[NCharCol] [nchar](10) NULL,
|
|
||||||
[NTextCol] [ntext] NULL,
|
|
||||||
[NumCol] [numeric](18, 0) NULL,
|
|
||||||
[NVarCharCol] [nvarchar](50) NULL,
|
|
||||||
[NVarCharMaxCol] [nvarchar](max) NULL,
|
|
||||||
[RealCol] [real] NULL,
|
|
||||||
[SmallDTCol] [smalldatetime] NULL,
|
|
||||||
[SmallIntCol] [smallint] NULL,
|
|
||||||
[SmallMoneyCol] [smallmoney] NULL,
|
|
||||||
[TextCol] [text] NULL,
|
|
||||||
[TimeCol] [time](7) NULL,
|
|
||||||
[TinyIntCol] [tinyint] NULL,
|
|
||||||
[Guidcol] [uniqueidentifier] NULL,
|
|
||||||
[VarbinaryCol] [varbinary](50) NULL,
|
|
||||||
[VarbinaryMaxCol] [varbinary](max) NULL,
|
|
||||||
[VarcharCol] [varchar](50) NULL,
|
|
||||||
[VarcharMaxCol] [varchar](max) NULL,
|
|
||||||
[XmlCol] [xml] NULL
|
|
||||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
";
|
|
||||||
|
|
||||||
$stmt = $conn->query( $create_query );
|
|
||||||
|
|
||||||
for ($i =0; $i<= 0 ; ++ $i)
|
|
||||||
{
|
|
||||||
$insert_query =
|
|
||||||
|
|
||||||
" INSERT INTO " .$table2 . " VALUES (".
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
"0" . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
"Convert(date, ". $date_col[$i] . $closing_brace .
|
|
||||||
"Convert(datetime, ". $date_col[$i] . $closing_brace .
|
|
||||||
"Convert(datetime2(7),". $date_col[$i] . $closing_brace .
|
|
||||||
"Convert(datetimeoffset(7)," . $date_col[$i] . $closing_brace .
|
|
||||||
$decimal_col[$i] . $comma .
|
|
||||||
$decimal_col[$i] .$comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$decimal_col[$i] . $comma .
|
|
||||||
$string_col[$i]. $comma .
|
|
||||||
$large_string_col[$i]. $comma.
|
|
||||||
$int_col[$i]. $comma .
|
|
||||||
$string_col[$i]. $comma .
|
|
||||||
$large_string_col[$i]. $comma .
|
|
||||||
$decimal_col[$i]. $comma .
|
|
||||||
"Convert(smalldatetime, ". $date_col[$i]. $closing_brace .
|
|
||||||
$int_col[$i]. $comma .
|
|
||||||
$decimal_col[$i]. $comma .
|
|
||||||
$large_string_col[$i]. $comma .
|
|
||||||
"Convert(time(7), ". $date_col[$i] . $closing_brace .
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$guid_col[$i] . $comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$large_string_col[$i] . $comma .
|
|
||||||
$xml_col[$i] .
|
|
||||||
")";
|
|
||||||
|
|
||||||
$stmt = $conn->query ($insert_query );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(Exception $e)
|
|
||||||
{
|
|
||||||
var_dump( $e);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function teardown()
|
function teardown()
|
||||||
{
|
{
|
||||||
// TBD
|
// TBD
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// looks like an additional file (in addition to pdo_test_base.inc) may be needed for these PHPTs
|
// looks like an additional file (in addition to pdo_test_base.inc) may be needed for these PHPTs
|
||||||
// to be runnable from the MSSQL teams' internal proprietary test running system
|
// to be runnable from the MSSQL teams' internal proprietary test running system
|
||||||
//
|
//
|
||||||
require 'MsData.inc';
|
|
||||||
|
|
||||||
function isAEQualified($conn)
|
function isAEQualified($conn)
|
||||||
{
|
{
|
||||||
|
@ -127,19 +126,21 @@ class ColumnMeta
|
||||||
{
|
{
|
||||||
public $dataType; //a string that includes the size of the type if necessary (e.g., decimal(10,5))
|
public $dataType; //a string that includes the size of the type if necessary (e.g., decimal(10,5))
|
||||||
public $colName; //column name
|
public $colName; //column name
|
||||||
public $encType; //randomized or deterministic; default is deterministic
|
|
||||||
public $options; //a string that is null by default (e.g. NOT NULL Identity (1,1) )
|
public $options; //a string that is null by default (e.g. NOT NULL Identity (1,1) )
|
||||||
|
public $encType; //randomized or deterministic; default is deterministic
|
||||||
|
public $forceEncrypt; //force encryption on a datatype no supported by Column Encrypton
|
||||||
|
|
||||||
public function __construct($dataType, $colName = null, $options = null, $encType = "deterministic")
|
public function __construct($dataType, $colName = null, $options = null, $encType = "deterministic", $forceEncrypt = false)
|
||||||
{
|
{
|
||||||
if (is_null($colName)) {
|
if (is_null($colName)) {
|
||||||
$this->colName = get_default_colname($dataType);
|
$this->colName = getDefaultColName($dataType);
|
||||||
} else {
|
} else {
|
||||||
$this->colName = $colName;
|
$this->colName = $colName;
|
||||||
}
|
}
|
||||||
$this->dataType = $dataType;
|
$this->dataType = $dataType;
|
||||||
$this->encType = $encType;
|
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
$this->encType = $encType;
|
||||||
|
$this->forceEncrypt = $forceEncrypt;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return string column definition for creating a table
|
* @return string column definition for creating a table
|
||||||
|
@ -150,7 +151,7 @@ class ColumnMeta
|
||||||
$append = " ";
|
$append = " ";
|
||||||
|
|
||||||
// an identity column is not encrypted because a select query with identity column as the where clause is often run and the user want to have to bind parameter every time
|
// an identity column is not encrypted because a select query with identity column as the where clause is often run and the user want to have to bind parameter every time
|
||||||
if (isColEncrypted() && stripos($this->options, "identity") === false) {
|
if (isColEncrypted() && $this->isEncryptableType() && stripos($this->options, "identity") === false) {
|
||||||
$cekName = getCekName();
|
$cekName = getCekName();
|
||||||
if (stripos($this->dataType, "char") !== false) {
|
if (stripos($this->dataType, "char") !== false) {
|
||||||
$append .= "COLLATE Latin1_General_BIN2 ";
|
$append .= "COLLATE Latin1_General_BIN2 ";
|
||||||
|
@ -161,6 +162,19 @@ class ColumnMeta
|
||||||
$colDef = "[" . $this->colName . "] " . $this->dataType . $append;
|
$colDef = "[" . $this->colName . "] " . $this->dataType . $append;
|
||||||
return $colDef;
|
return $colDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool if the datatype for this column is encryptable
|
||||||
|
*/
|
||||||
|
public function isEncryptableType()
|
||||||
|
{
|
||||||
|
$unsupportedTypes = array("money", "smallmoney", "image", "ntext", "text", "xml", "sql_variant");
|
||||||
|
if (!$this->forceEncrypt && in_array(strtolower($this->dataType), $unsupportedTypes)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,9 +197,10 @@ function getDefaultColName($dataType)
|
||||||
* @param array $inputs : an associative array column name and its value; value may be a literal value or a ColumnMeta object
|
* @param array $inputs : an associative array column name and its value; value may be a literal value or a ColumnMeta object
|
||||||
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
|
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
|
||||||
* for creating table with datatypes not support for encryption
|
* for creating table with datatypes not support for encryption
|
||||||
|
* @param string $tableOption : table options appended to the end of a create table statement
|
||||||
* @return int reporting the number of rows affected (should always be 0 for creating table)
|
* @return int reporting the number of rows affected (should always be 0 for creating table)
|
||||||
*/
|
*/
|
||||||
function createTable($conn, $tbname, $columnMetaArr, $disableCE = false)
|
function createTable($conn, $tbname, $columnMetaArr, $tableOption = '', $disableCE = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
dropTable($conn, $tbname);
|
dropTable($conn, $tbname);
|
||||||
|
@ -202,7 +217,7 @@ function createTable($conn, $tbname, $columnMetaArr, $disableCE = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$colDef = rtrim($colDef, ", ");
|
$colDef = rtrim($colDef, ", ");
|
||||||
$createSql = "CREATE TABLE $tbname ($colDef)";
|
$createSql = "CREATE TABLE $tbname ($colDef) $tableOption";
|
||||||
$numRows = $conn->exec($createSql);
|
$numRows = $conn->exec($createSql);
|
||||||
return $numRows;
|
return $numRows;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
@ -231,14 +246,14 @@ class BindParamOp
|
||||||
$this->variable = $variable;
|
$this->variable = $variable;
|
||||||
|
|
||||||
$pdoParams = array("PDO::PARAM_BOOL", "PDO::PARAM_NULL", "PDO::PARAM_INT", "PDO::PARAM_STR", "PDO::PARAM_LOB");
|
$pdoParams = array("PDO::PARAM_BOOL", "PDO::PARAM_NULL", "PDO::PARAM_INT", "PDO::PARAM_STR", "PDO::PARAM_LOB");
|
||||||
if (in_array($pdoType, $pdoParams)) {
|
if (in_array($pdoType, $pdoParams) || is_null($pdoType)) {
|
||||||
$this->pdoType = $pdoType;
|
$this->pdoType = $pdoType;
|
||||||
} else {
|
} else {
|
||||||
prinft("BindParamOp construct: The pdoType provided must be one of PDO::PARAM_BOOL, PDO::PARAM_NULL, PDO::PARAM_INT, PDO::PARAM_STR, or PDO::PARAM_LOB.\n");
|
printf("BindParamOp construct: The pdoType provided must be one of PDO::PARAM_BOOL, PDO::PARAM_NULL, PDO::PARAM_INT, PDO::PARAM_STR, or PDO::PARAM_LOB.\n");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($length >= 0) {
|
if ($length >= 0 || is_null($length)) {
|
||||||
$this->length = $length;
|
$this->length = $length;
|
||||||
} else {
|
} else {
|
||||||
printf("BindParamOp construct: The length provided must be greater or equal to 0.\n");
|
printf("BindParamOp construct: The length provided must be greater or equal to 0.\n");
|
||||||
|
@ -246,7 +261,7 @@ class BindParamOp
|
||||||
}
|
}
|
||||||
|
|
||||||
$encodingAttrs = array("PDO::SQLSRV_ENCODING_BINARY", "PDO::SQLSRV_ENCODING_SYSTEM", "PDO::SQLSRV_ENCODING_UTF8", "PDO::SQLSRV_ENCODING_DEFAULT");
|
$encodingAttrs = array("PDO::SQLSRV_ENCODING_BINARY", "PDO::SQLSRV_ENCODING_SYSTEM", "PDO::SQLSRV_ENCODING_UTF8", "PDO::SQLSRV_ENCODING_DEFAULT");
|
||||||
if (in_array($options, $encodingAttrs)) {
|
if (in_array($options, $encodingAttrs) || is_null($options)) {
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
} else {
|
} else {
|
||||||
printf("BindParamOp construct: The option provided must be one of PDO::SQLSRV_ENCODING_BINARY, PDO::SQLSRV_ENCODING_SYSTEM, PDO::SQLSRV_ENCODING_UTF8, PDO::SQLSRV_ENCODING_DEFAULT");
|
printf("BindParamOp construct: The option provided must be one of PDO::SQLSRV_ENCODING_BINARY, PDO::SQLSRV_ENCODING_SYSTEM, PDO::SQLSRV_ENCODING_UTF8, PDO::SQLSRV_ENCODING_DEFAULT");
|
||||||
|
@ -508,146 +523,6 @@ function isColEncrypted()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create and insert
|
|
||||||
function create_and_insert_table1($conn)
|
|
||||||
{
|
|
||||||
global $string_col, $date_col, $large_string_col, $xml_col, $binary_col, $int_col, $decimal_col, $guid_col, $null_col, $comma, $closing_brace, $table1;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$create_query =
|
|
||||||
|
|
||||||
"IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'" . $table1 . "') AND type in (N'U'))
|
|
||||||
DROP TABLE " . $table1 .
|
|
||||||
|
|
||||||
" CREATE TABLE [dbo].[" . $table1 . "](
|
|
||||||
[IntCol] [int] NULL,
|
|
||||||
[CharCol] [char](10) NULL,
|
|
||||||
[NCharCol] [nchar](10) NULL,
|
|
||||||
[DateTimeCol] [datetime] NULL,
|
|
||||||
[VarcharCol] [varchar](50) NULL,
|
|
||||||
[NVarCharCol] [nvarchar](50) NULL,
|
|
||||||
[FloatCol] [float] NULL,
|
|
||||||
[XmlCol] [xml] NULL
|
|
||||||
) ON [PRIMARY]
|
|
||||||
";
|
|
||||||
|
|
||||||
$conn->query($create_query);
|
|
||||||
|
|
||||||
for ($i = 0 ; $i <= 1; ++ $i) {
|
|
||||||
$insert_query =
|
|
||||||
"INSERT INTO PDO_Types_1 VALUES (".
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
"Convert(datetime, ". $date_col[$i] . ")" . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$decimal_col[$i] . $comma .
|
|
||||||
$xml_col[$i] .
|
|
||||||
")";
|
|
||||||
|
|
||||||
$conn->query($insert_query);
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
var_dump($e);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function create_and_insert_table2($conn)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
//Timestamp is not present.
|
|
||||||
//VARIANT is not supported.
|
|
||||||
global $string_col, $date_col, $large_string_col, $xml_col, $binary_col, $int_col, $decimal_col, $guid_col, $null_col, $comma, $closing_brace, $table1, $table2;
|
|
||||||
|
|
||||||
$create_query =
|
|
||||||
"IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'".$table2."') AND type in (N'U')) DROP TABLE " . $table2 .
|
|
||||||
|
|
||||||
" CREATE TABLE " .$table2 . " (
|
|
||||||
[BigIntCol] [bigint] NULL,
|
|
||||||
[BinaryCol] [binary](5) NULL,
|
|
||||||
[BitCol] [bit] NULL,
|
|
||||||
[CharCol] [char](10) NULL,
|
|
||||||
[DateCol] [date] NULL,
|
|
||||||
[DateTimeCol] [datetime] NULL,
|
|
||||||
[DateTime2Col] [datetime2](7) NULL,
|
|
||||||
[DTOffsetCol] [datetimeoffset](7) NULL,
|
|
||||||
[DecimalCol] [decimal](18, 0) NULL,
|
|
||||||
[FloatCol] [float] NULL,
|
|
||||||
[ImageCol] [image] NULL,
|
|
||||||
[IntCol] [int] NULL,
|
|
||||||
[MoneyCol] [money] NULL,
|
|
||||||
[NCharCol] [nchar](10) NULL,
|
|
||||||
[NTextCol] [ntext] NULL,
|
|
||||||
[NumCol] [numeric](18, 0) NULL,
|
|
||||||
[NVarCharCol] [nvarchar](50) NULL,
|
|
||||||
[NVarCharMaxCol] [nvarchar](max) NULL,
|
|
||||||
[RealCol] [real] NULL,
|
|
||||||
[SmallDTCol] [smalldatetime] NULL,
|
|
||||||
[SmallIntCol] [smallint] NULL,
|
|
||||||
[SmallMoneyCol] [smallmoney] NULL,
|
|
||||||
[TextCol] [text] NULL,
|
|
||||||
[TimeCol] [time](7) NULL,
|
|
||||||
[TinyIntCol] [tinyint] NULL,
|
|
||||||
[Guidcol] [uniqueidentifier] NULL,
|
|
||||||
[VarbinaryCol] [varbinary](50) NULL,
|
|
||||||
[VarbinaryMaxCol] [varbinary](max) NULL,
|
|
||||||
[VarcharCol] [varchar](50) NULL,
|
|
||||||
[VarcharMaxCol] [varchar](max) NULL,
|
|
||||||
[XmlCol] [xml] NULL
|
|
||||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
|
|
||||||
|
|
||||||
";
|
|
||||||
|
|
||||||
$stmt = $conn->query($create_query);
|
|
||||||
|
|
||||||
for ($i =0; $i<= 0 ; ++ $i) {
|
|
||||||
$insert_query =
|
|
||||||
|
|
||||||
" INSERT INTO " .$table2 . " VALUES (".
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
"0" . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
"Convert(date, ". $date_col[$i] . $closing_brace .
|
|
||||||
"Convert(datetime, ". $date_col[$i] . $closing_brace .
|
|
||||||
"Convert(datetime2(7),". $date_col[$i] . $closing_brace .
|
|
||||||
"Convert(datetimeoffset(7)," . $date_col[$i] . $closing_brace .
|
|
||||||
$decimal_col[$i] . $comma .
|
|
||||||
$decimal_col[$i] .$comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$decimal_col[$i] . $comma .
|
|
||||||
$string_col[$i]. $comma .
|
|
||||||
$large_string_col[$i]. $comma.
|
|
||||||
$int_col[$i]. $comma .
|
|
||||||
$string_col[$i]. $comma .
|
|
||||||
$large_string_col[$i]. $comma .
|
|
||||||
$decimal_col[$i]. $comma .
|
|
||||||
"Convert(smalldatetime, ". $date_col[$i]. $closing_brace .
|
|
||||||
$int_col[$i]. $comma .
|
|
||||||
$decimal_col[$i]. $comma .
|
|
||||||
$large_string_col[$i]. $comma .
|
|
||||||
"Convert(time(7), ". $date_col[$i] . $closing_brace .
|
|
||||||
$int_col[$i] . $comma .
|
|
||||||
$guid_col[$i] . $comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
$binary_col[$i] . $comma .
|
|
||||||
$string_col[$i] . $comma .
|
|
||||||
$large_string_col[$i] . $comma .
|
|
||||||
$xml_col[$i] .
|
|
||||||
")";
|
|
||||||
|
|
||||||
$stmt = $conn->query($insert_query);
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
var_dump($e);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function teardown()
|
function teardown()
|
||||||
{
|
{
|
||||||
// TBD
|
// TBD
|
||||||
|
@ -1366,7 +1241,7 @@ function CreateTableEx($conn, $tableName, $dataType)
|
||||||
{
|
{
|
||||||
Trace("Creating table $tableName ...");
|
Trace("Creating table $tableName ...");
|
||||||
$tsql = "CREATE TABLE [$tableName] ($dataType)";
|
$tsql = "CREATE TABLE [$tableName] ($dataType)";
|
||||||
DropTable($conn, $tableName);
|
dropTable($conn, $tableName);
|
||||||
|
|
||||||
if (IsPdoMode()) {
|
if (IsPdoMode()) {
|
||||||
$outcome = $conn->exec($tsql);
|
$outcome = $conn->exec($tsql);
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
<?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';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
205
test/functional/pdo_sqlsrv/MsData_PDO_AllTypes.inc
Normal file
205
test/functional/pdo_sqlsrv/MsData_PDO_AllTypes.inc
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
<?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
|
||||||
|
$int_col = array(1, 2);
|
||||||
|
|
||||||
|
$bin = fopen('php://memory', 'a');
|
||||||
|
fwrite($bin, '00');
|
||||||
|
rewind($bin);
|
||||||
|
$binary_col = array($bin, $bin);
|
||||||
|
|
||||||
|
$string_col = array("STRINGCOL1", "STRINGCOL2");
|
||||||
|
|
||||||
|
$decimal_col = array(111.111, 222.222);
|
||||||
|
|
||||||
|
$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.";
|
||||||
|
|
||||||
|
$date_col = array('2000-11-11', '2000-11-11');
|
||||||
|
$datetime_col = array('2000-11-11 11:11:11.111', '2000-11-11 11:11:11.222');
|
||||||
|
$datetime2_col = array('2000-11-11 11:11:11.111', '2000-11-11 11:11:11.222');
|
||||||
|
$dtoffset_col = array('2000-11-11 11:11:11.111 +00:00', '2000-11-11 11:11:11.222 +00:00');
|
||||||
|
$smalldt_col = array('2000-11-11 11:11:00', '2000-11-11 11:11:00');
|
||||||
|
$timeCol = array('11:11:11.111', '11:11:11.222');
|
||||||
|
|
||||||
|
$large_string_col = array(" 1 " . $large_string . "", " 2 " . $large_string . "");
|
||||||
|
|
||||||
|
$guid_col = array("AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA", "BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB");
|
||||||
|
|
||||||
|
$xml_col = array("<xml> 1 " . $large_string . "</xml>", "<xml> 2 " . $large_string . "</xml>");
|
||||||
|
|
||||||
|
$null_col = 'null';
|
||||||
|
|
||||||
|
$mainTypesClass = 'PDO_MainTypesClass';
|
||||||
|
class PDO_MainTypesClass
|
||||||
|
{
|
||||||
|
public $IntCol;
|
||||||
|
public $CharCol;
|
||||||
|
public $NCharCol;
|
||||||
|
public $DateTimeCol;
|
||||||
|
public $VarcharCol;
|
||||||
|
public $NVarCharCol;
|
||||||
|
public $FloatCol;
|
||||||
|
public $XmlCol;
|
||||||
|
|
||||||
|
public 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTableMainTypes($conn, $tbname)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
$columnMetaArr = array("IntCol" => "int",
|
||||||
|
"CharCol" => "char(10)",
|
||||||
|
"NCharCol" => "nchar(10)",
|
||||||
|
"DateTimeCol" => "datetime",
|
||||||
|
"VarcharCol" => "varchar(50)",
|
||||||
|
"NVarCharCol" => "nvarchar(50)",
|
||||||
|
"FloatCol" => "float",
|
||||||
|
"XmlCol" => "xml");
|
||||||
|
createTable($conn, $tbname, $columnMetaArr, "ON [PRIMARY]");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
var_dump($e);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertIntoTableMainTypes($conn, $tbname, $rownum)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
global $string_col, $date_col, $large_string_col, $xml_col, $binary_col, $int_col, $decimal_col, $guid_col, $datetime_col, $datetime2_col, $dtoffset_col, $smalldt_col, $timeCol;
|
||||||
|
|
||||||
|
$inputs = array("IntCol" => $int_col[$rownum],
|
||||||
|
"CharCol" => $string_col[$rownum],
|
||||||
|
"NCharCol" => $string_col[$rownum],
|
||||||
|
"DateTimeCol" => $datetime_col[$rownum],
|
||||||
|
"VarcharCol" => $string_col[$rownum],
|
||||||
|
"NVarCharCol" => $string_col[$rownum],
|
||||||
|
"FloatCol" => $decimal_col[$rownum],
|
||||||
|
"XmlCol" => $xml_col[$rownum]);
|
||||||
|
$stmt = insertRow($conn, $tbname, $inputs, "prepareBindParam");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
var_dump($e);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAndInsertTableMainTypes($conn, $tbname, $rows = array(0, 1))
|
||||||
|
{
|
||||||
|
createTableMainTypes($conn, $tbname);
|
||||||
|
foreach ($rows as $rownum) {
|
||||||
|
insertIntoTableMainTypes($conn, $tbname, $rownum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTableAllTypes($conn, $tbname)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
$columnMetaArr = array("BigIntCol" => "bigint",
|
||||||
|
"BinaryCol" => "binary(5)",
|
||||||
|
"BitCol" => "bit",
|
||||||
|
"CharCol" => "char(10)",
|
||||||
|
"DateCol" => "date",
|
||||||
|
"DateTimeCol" => "datetime",
|
||||||
|
"DateTime2Col" => "datetime2(7)",
|
||||||
|
"DTOffsetCol" => "datetimeoffset(7)",
|
||||||
|
"DecimalCol" => "decimal(18,0)",
|
||||||
|
"FloatCol" => "float",
|
||||||
|
"ImageCol" => "image",
|
||||||
|
"IntCol" => "int",
|
||||||
|
"MoneyCol" => "money",
|
||||||
|
"NCharCol" => "nchar(10)",
|
||||||
|
"NTextCol" => "ntext",
|
||||||
|
"NumCol" => "numeric(18,0)",
|
||||||
|
"NVarCharCol" => "nvarchar(50)",
|
||||||
|
"NVarCharMaxCol" => "nvarchar(max)",
|
||||||
|
"RealCol" => "real",
|
||||||
|
"SmallDTCol" => "smalldatetime",
|
||||||
|
"SmallIntCol" => "smallint",
|
||||||
|
"SmallMoneyCol" => "smallmoney",
|
||||||
|
"TextCol" => "text",
|
||||||
|
"TimeCol" => "time(7)",
|
||||||
|
"TinyIntCol" => "tinyint",
|
||||||
|
"Guidcol" => "uniqueidentifier",
|
||||||
|
"VarbinaryCol" => "varbinary(50)",
|
||||||
|
"VarbinaryMaxCol" => "varbinary(max)",
|
||||||
|
"VarcharCol" => "varchar(50)",
|
||||||
|
"VarcharMaxCol" => "varchar(max)",
|
||||||
|
"XmlCol" => "xml");
|
||||||
|
createTable($conn, $tbname, $columnMetaArr, "ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
var_dump($e);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertIntoTableAllTypes($conn, $tbname, $rownum)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
global $string_col, $date_col, $large_string_col, $xml_col, $binary_col, $int_col, $decimal_col, $guid_col, $datetime_col, $datetime2_col, $dtoffset_col, $smalldt_col, $timeCol;
|
||||||
|
|
||||||
|
$inputs = array("BigIntCol" => $int_col[$rownum],
|
||||||
|
"BinaryCol" => new BindParamOp(2, $binary_col[$rownum], "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
|
"BitCol" => 0,
|
||||||
|
"CharCol" => $string_col[$rownum],
|
||||||
|
"DateCol" => $date_col[$rownum],
|
||||||
|
"DateTimeCol" => $datetime_col[$rownum],
|
||||||
|
"DateTime2Col" => $datetime2_col[$rownum],
|
||||||
|
"DTOffsetCol" => $dtoffset_col[$rownum],
|
||||||
|
"DecimalCol" => $decimal_col[$rownum],
|
||||||
|
"FloatCol" => $decimal_col[$rownum],
|
||||||
|
"ImageCol" => new BindParamOp(11, $binary_col[$rownum], "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
|
"IntCol" => $int_col[$rownum],
|
||||||
|
"MoneyCol" => $decimal_col[$rownum],
|
||||||
|
"NCharCol" => $string_col[$rownum],
|
||||||
|
"NTextCol" => $large_string_col[$rownum],
|
||||||
|
"NumCol" => $int_col[$rownum],
|
||||||
|
"NVarCharCol" => $string_col[$rownum],
|
||||||
|
"NVarCharMaxCol" => $large_string_col[$rownum],
|
||||||
|
"RealCol" => $decimal_col[$rownum],
|
||||||
|
"SmallDTCol" => $smalldt_col[$rownum],
|
||||||
|
"SmallIntCol" => $int_col[$rownum],
|
||||||
|
"SmallMoneyCol" => $decimal_col[$rownum],
|
||||||
|
"TextCol" => $large_string_col[$rownum],
|
||||||
|
"TimeCol" => $timeCol[$rownum],
|
||||||
|
"TinyIntCol" => $int_col[$rownum],
|
||||||
|
"Guidcol" => $guid_col[$rownum],
|
||||||
|
"VarbinaryCol" => new BindParamOp(27, $binary_col[$rownum], "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
|
"VarbinaryMaxCol" => new BindParamOp(28, $binary_col[$rownum], "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
|
"VarcharCol" => $string_col[$rownum],
|
||||||
|
"VarcharMaxCol" => $large_string_col[$rownum],
|
||||||
|
"XmlCol" => $xml_col[$rownum]);
|
||||||
|
$stmt = insertRow($conn, $tbname, $inputs, "prepareBindParam");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
var_dump($e);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAndInsertTableAllTypes($conn, $tbname, $rows = array(0))
|
||||||
|
{
|
||||||
|
createTableAllTypes($conn, $tbname);
|
||||||
|
foreach ($rows as $rownum) {
|
||||||
|
insertIntoTableAllTypes($conn, $tbname, $rownum);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,60 +1,23 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PDO Drivers Info Test
|
PDO Drivers Info Test
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Verifies the functionality of "PDO:getAvailableDrivers()”.
|
Verifies the functionality of "PDO:getAvailableDrivers()".
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
try {
|
||||||
|
|
||||||
function DriversInfo()
|
|
||||||
{
|
|
||||||
include 'MsSetup.inc';
|
|
||||||
|
|
||||||
$testName = "PDO - Drivers";
|
|
||||||
StartTest($testName);
|
|
||||||
|
|
||||||
$drivers = PDO::getAvailableDrivers();
|
$drivers = PDO::getAvailableDrivers();
|
||||||
if (in_array("sqlsrv", $drivers))
|
if (!in_array("sqlsrv", $drivers)) {
|
||||||
{
|
|
||||||
$count = count($drivers);
|
|
||||||
for ($i = 0; $i < $count; $i++)
|
|
||||||
{
|
|
||||||
Trace("Driver #".($i + 1).": ".$drivers[$i]."\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("$PhpDriver is missing.\n");
|
printf("$PhpDriver is missing.\n");
|
||||||
|
} else {
|
||||||
|
printf("Done\n");
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
EndTest($testName);
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// Repro
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
function Repro()
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DriversInfo();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repro();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test "PDO - Drivers" completed successfully.
|
Done
|
||||||
|
|
|
@ -5,57 +5,26 @@ Verifies the functionality of PDO with phpinfo().
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
try {
|
||||||
|
|
||||||
function DriversInfo()
|
|
||||||
{
|
|
||||||
include 'MsSetup.inc';
|
|
||||||
|
|
||||||
$testName = "PDO - phpinfo";
|
|
||||||
StartTest($testName);
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
phpinfo();
|
phpinfo();
|
||||||
$info = ob_get_contents();
|
$info = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
// Check phpinfo() data
|
// Check phpinfo() data
|
||||||
if (stristr($info, "PDO support => enabled") === false)
|
if (stristr($info, "PDO support => enabled") === false) {
|
||||||
{
|
|
||||||
printf("PDO is not enabled\n");
|
printf("PDO is not enabled\n");
|
||||||
|
} elseif (stristr($info, "pdo_sqlsrv support => enabled") === false) {
|
||||||
|
printf("Cannot find PDO_SQLSRV driver in phpinfo() output\n");
|
||||||
|
} else {
|
||||||
|
printf("Done\n");
|
||||||
}
|
}
|
||||||
else if (stristr($info, "pdo_sqlsrv support => enabled") === false)
|
} catch (Exception $e) {
|
||||||
{
|
echo $e->getMessage();
|
||||||
printf("Cannot find PDO driver line in phpinfo() output\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
EndTest($testName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// Repro
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
function Repro()
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DriversInfo();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repro();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test "PDO - phpinfo" completed successfully.
|
Done
|
||||||
|
|
|
@ -6,57 +6,32 @@ Verifies as well that invalid connection attempts fail as expected.
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsSetup.inc");
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
function ConnectionTest()
|
try {
|
||||||
{
|
|
||||||
include 'MsSetup.inc';
|
|
||||||
|
|
||||||
$testName = "PDO Connection";
|
|
||||||
StartTest($testName);
|
|
||||||
|
|
||||||
// Invalid connection attempt => errors are expected
|
// Invalid connection attempt => errors are expected
|
||||||
Trace("Invalid connection attempt (to a non-existing server) ....\n");
|
$serverName="InvalidServerName";
|
||||||
$conn1 = PDOConnect('PDO', "InvalidServerName", $uid, $pwd, false);
|
|
||||||
if ($conn1)
|
$dsn = getDSN($serverName, $databaseName);
|
||||||
{
|
$conn1 = new PDO($dsn, $uid, $pwd, $connectionOptions);
|
||||||
|
if ($conn1) {
|
||||||
printf("Invalid connection attempt should have failed.\n");
|
printf("Invalid connection attempt should have failed.\n");
|
||||||
}
|
}
|
||||||
$conn1 = null;
|
unset($conn1);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
unset($conn1);
|
||||||
|
echo "Done\n";
|
||||||
|
}
|
||||||
|
try {
|
||||||
// Valid connection attempt => no errors are expected
|
// Valid connection attempt => no errors are expected
|
||||||
Trace("\nValid connection attempt (to $server) ....\n");
|
$conn2 = connect();
|
||||||
$conn2 = Connect();
|
unset($conn2);
|
||||||
$conn2 = null;
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
EndTest($testName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// Repro
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
function Repro()
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ConnectionTest();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repro();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test "PDO Connection" completed successfully.
|
Done
|
||||||
|
|
||||||
|
|
|
@ -5,76 +5,46 @@ Verification of PDO::errorCode()
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
try {
|
||||||
function CheckErrorCode()
|
$conn1 = connect();
|
||||||
{
|
checkError(1, $conn1);
|
||||||
include 'MsSetup.inc';
|
|
||||||
|
|
||||||
$testName = "PDO Connection - Error Code";
|
|
||||||
|
|
||||||
StartTest($testName);
|
|
||||||
|
|
||||||
$conn1 = Connect();
|
|
||||||
CheckError(1, $conn1, '00000');
|
|
||||||
|
|
||||||
// Prepare test table
|
// Prepare test table
|
||||||
$table1 = $tableName."1";
|
$table1 = "Table1";
|
||||||
$table2 = $tableName."2";
|
createTable($conn1, $table1, array(new ColumnMeta("int", "id", "NOT NULL PRIMARY KEY"), "label" => "varchar(10)"));
|
||||||
CreateTableEx($conn1, $table1, "id int NOT NULL PRIMARY KEY, label VARCHAR(10)", null);
|
|
||||||
|
|
||||||
// Check errors when executing SELECT queries
|
// Check errors when executing SELECT queries
|
||||||
$stmt1 = $conn1->prepare("SELECT id, label FROM [$table1]");
|
$stmt1 = $conn1->prepare("SELECT id, label FROM [$table1]");
|
||||||
CheckError(2, $conn1);
|
checkError(2, $conn1);
|
||||||
CheckError(3, $stmt1);
|
checkError(3, $stmt1);
|
||||||
$stmt1->execute();
|
$stmt1->execute();
|
||||||
$stmt2 = &$stmt1;
|
$stmt2 = &$stmt1;
|
||||||
CheckError(4, $stmt1);
|
checkError(4, $stmt1);
|
||||||
$stmt1->closeCursor();
|
$stmt1->closeCursor();
|
||||||
|
|
||||||
DropTable($conn1, $table1);
|
dropTable($conn1, $table1);
|
||||||
CheckError(5, $conn1);
|
checkError(5, $conn1);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
$stmt1 = null;
|
unset($stmt);
|
||||||
$conn1 = null;
|
unset($conn);
|
||||||
|
echo "Done\n";
|
||||||
EndTest($testName);
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckError($offset, &$obj, $expected = '00000')
|
function checkError($offset, &$obj)
|
||||||
{
|
{
|
||||||
$code = $obj->errorCode();
|
$code = $obj->errorCode();
|
||||||
if (($code != $expected) && (($expected != '00000') || ($code !='')))
|
$expected = '00000';
|
||||||
{
|
if ($code != $expected && !empty($code)) {
|
||||||
printf("[%03d] Expecting error code '%s' got code '%s'\n",
|
printf("[%03d] Expecting error code '%s' got code '%s'\n", $offset, $expected, $code);
|
||||||
$offset, $expected, $code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// Repro
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
function Repro()
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CheckErrorCode();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repro();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test "PDO Connection - Error Code" completed successfully.
|
Done
|
||||||
|
|
|
@ -5,112 +5,81 @@ Verification of PDO::errorInfo()
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
function CheckErrorInfo()
|
try {
|
||||||
{
|
$conn1 = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
include 'MsSetup.inc';
|
checkError(1, $conn1, '00000');
|
||||||
|
|
||||||
$testName = "PDO Connection - Error Info";
|
|
||||||
StartTest($testName);
|
|
||||||
|
|
||||||
$conn1 = Connect();
|
|
||||||
CheckError(1, $conn1, '00000');
|
|
||||||
|
|
||||||
// Prepare test table
|
// Prepare test table
|
||||||
$table1 = $tableName."1";
|
$table1 = "Table1";
|
||||||
$table2 = $tableName."2";
|
$table2 = "Table2";
|
||||||
CreateTableEx($conn1, $table1, "id int NOT NULL PRIMARY KEY, label VARCHAR(10)", null);
|
createTable($conn1, $table1, array(new ColumnMeta("int", "id", "NOT NULL PRIMARY KEY"), "label" => "varchar(10)"));
|
||||||
|
|
||||||
// Check errors when executing SELECT queries
|
// Check errors when executing SELECT queries
|
||||||
$stmt1 = $conn1->prepare("SELECT id, label FROM [$table1]");
|
$stmt1 = $conn1->prepare("SELECT id, label FROM [$table1]");
|
||||||
CheckError(2, $conn1);
|
checkError(2, $conn1);
|
||||||
CheckError(3, $stmt1);
|
checkError(3, $stmt1);
|
||||||
$stmt1->execute();
|
$stmt1->execute();
|
||||||
$stmt2 = &$stmt1;
|
$stmt2 = &$stmt1;
|
||||||
CheckError(4, $stmt1);
|
checkError(4, $stmt1);
|
||||||
$stmt1->closeCursor();
|
$stmt1->closeCursor();
|
||||||
|
|
||||||
|
dropTable($conn1, $table1);
|
||||||
//DropTable($conn1, $table1);
|
|
||||||
@$stmt1->execute();
|
@$stmt1->execute();
|
||||||
CheckError(5, $conn1);
|
checkError(5, $conn1);
|
||||||
//CheckError(6, $stmt1, '42S02');
|
checkError(6, $stmt1, '42S02');
|
||||||
//CheckError(7, $stmt2, '42S02');
|
checkError(7, $stmt2, '42S02');
|
||||||
$stmt1->closeCursor();
|
$stmt1->closeCursor();
|
||||||
|
|
||||||
DropTable($conn1, $table2);
|
dropTable($conn1, $table2);
|
||||||
$conn2 = &$conn1;
|
$conn2 = &$conn1;
|
||||||
//@$conn1->query("SELECT id, label FROM [$table2]");
|
@$conn1->query("SELECT id, label FROM [$table2]");
|
||||||
//CheckError(8, $conn1, '42S02');
|
checkError(8, $conn1, '42S02');
|
||||||
//CheckError(9, $conn2, '42S02');
|
checkError(9, $conn2, '42S02');
|
||||||
|
|
||||||
|
createTable($conn1, $table1, array(new ColumnMeta("int", "id", "NOT NULL PRIMARY KEY"), "label" => "varchar(10)"));
|
||||||
|
|
||||||
CreateTableEx($conn1, $table1, "id int NOT NULL PRIMARY KEY, label VARCHAR(10)", null);
|
|
||||||
$stmt1 = $conn1->query("SELECT id, label FROM [$table1]");
|
$stmt1 = $conn1->query("SELECT id, label FROM [$table1]");
|
||||||
CheckError(10, $conn1);
|
checkError(10, $conn1);
|
||||||
CheckError(11, $stmt1);
|
checkError(11, $stmt1);
|
||||||
$stmt1->closeCursor();
|
$stmt1->closeCursor();
|
||||||
|
|
||||||
// @$conn1->query("SELECT id, label FROM [$table2]");
|
@$conn1->query("SELECT id, label FROM [$table2]");
|
||||||
// CheckError(12, $conn1, '42S02');
|
checkError(12, $conn1, '42S02');
|
||||||
// CheckError(13, $conn2, '42S02');
|
checkError(13, $conn2, '42S02');
|
||||||
CheckError(14, $stmt1);
|
checkError(14, $stmt1);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
DropTable($conn1, $table1);
|
dropTable($conn1, $table1);
|
||||||
$stmt1 = null;
|
unset($stmt1);
|
||||||
$conn1 = null;
|
unset($conn1);
|
||||||
|
echo "Done\n";
|
||||||
EndTest($testName);
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function CheckError($offset, &$obj, $expected = '00000')
|
function checkError($offset, &$obj, $expected = '00000')
|
||||||
{
|
{
|
||||||
$info = $obj->errorInfo();
|
$info = $obj->errorInfo();
|
||||||
$code = $info[0];
|
$code = $info[0];
|
||||||
|
|
||||||
if (($code != $expected) && (($expected != '00000') || ($code != '')))
|
if (($code != $expected) && (($expected != '00000') || ($code != ''))) {
|
||||||
{
|
printf("[%03d] Expecting error code '%s' got code '%s'\n", $offset, $expected, $code);
|
||||||
printf("[%03d] Expecting error code '%s' got code '%s'\n",
|
|
||||||
$offset, $expected, $code);
|
|
||||||
}
|
}
|
||||||
if ($expected != '00000')
|
if ($expected != '00000') {
|
||||||
{
|
if (!isset($info[1]) || ($info[1] == '')) {
|
||||||
if (!isset($info[1]) || ($info[1] == ''))
|
|
||||||
{
|
|
||||||
printf("[%03d] Driver-specific error code not set\n", $offset);
|
printf("[%03d] Driver-specific error code not set\n", $offset);
|
||||||
}
|
}
|
||||||
if (!isset($info[2]) || ($info[2] == ''))
|
if (!isset($info[2]) || ($info[2] == '')) {
|
||||||
{
|
printf("[%03d] Driver-specific error message not set\n", $offset);
|
||||||
printf("[%03d] Driver-specific error message.not set\n", $offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// Repro
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
function Repro()
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CheckErrorInfo();
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repro();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test "PDO Connection - Error Info" completed successfully.
|
Done
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_once("MsSetup.inc");
|
||||||
|
|
||||||
// Using the test database for two tables specifically constructed
|
// Using the test database for two tables specifically constructed
|
||||||
// for the connection resiliency tests
|
// for the connection resiliency tests
|
||||||
$dbName = $databaseName;
|
$dbName = $databaseName;
|
||||||
|
|
||||||
$tableName1 = "test_connres1";
|
$tableName1 = "test_connres1";
|
||||||
$tableName2 = "test_connres2";
|
$tableName2 = "test_connres2";
|
||||||
|
@ -12,73 +12,69 @@ $tableName2 = "test_connres2";
|
||||||
// Using generated tables will eventually allow us to put the
|
// Using generated tables will eventually allow us to put the
|
||||||
// connection resiliency tests on Github, since the integrated testing
|
// connection resiliency tests on Github, since the integrated testing
|
||||||
// from AppVeyor does not have AdventureWorks.
|
// from AppVeyor does not have AdventureWorks.
|
||||||
function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2 )
|
function generateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2)
|
||||||
{
|
{
|
||||||
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd );
|
try {
|
||||||
if ( $conn === false )
|
$conn = new PDO("sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd);
|
||||||
{
|
|
||||||
die ( print_r( sqlsrv_errors() ) );
|
// Create table
|
||||||
|
$sql = "CREATE TABLE $tableName1 (c1 INT, c2 VARCHAR(40))";
|
||||||
|
$stmt = $conn->query($sql);
|
||||||
|
|
||||||
|
// Insert data
|
||||||
|
$sql = "INSERT INTO $tableName1 VALUES ( ?, ? )";
|
||||||
|
for ($t = 100; $t < 116; $t++) {
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$ts = substr(sha1($t), 0, 5);
|
||||||
|
$params = array( $t,$ts );
|
||||||
|
$stmt->execute($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create table
|
||||||
|
$sql = "CREATE TABLE $tableName2 ( c1 INT, c2 VARCHAR(40) )";
|
||||||
|
$stmt = $conn->query($sql);
|
||||||
|
|
||||||
|
// Insert data
|
||||||
|
$sql = "INSERT INTO $tableName2 VALUES ( ?, ? )";
|
||||||
|
for ($t = 200; $t < 209; $t++) {
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$ts = substr(sha1($t), 0, 5);
|
||||||
|
$params = array( $t,$ts );
|
||||||
|
$stmt->execute($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($conn);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e->errorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create table
|
|
||||||
$sql = "CREATE TABLE $tableName1 ( c1 INT, c2 VARCHAR(40) )";
|
|
||||||
$stmt = $conn->query( $sql );
|
|
||||||
|
|
||||||
// Insert data
|
|
||||||
$sql = "INSERT INTO $tableName1 VALUES ( ?, ? )";
|
|
||||||
for( $t = 100; $t < 116; $t++ )
|
|
||||||
{
|
|
||||||
$stmt = $conn->prepare( $sql );
|
|
||||||
$ts = substr( sha1( $t ),0,5 );
|
|
||||||
$params = array( $t,$ts );
|
|
||||||
$stmt->execute( $params );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create table
|
|
||||||
$sql = "CREATE TABLE $tableName2 ( c1 INT, c2 VARCHAR(40) )";
|
|
||||||
$stmt = $conn->query( $sql );
|
|
||||||
|
|
||||||
// Insert data
|
|
||||||
$sql = "INSERT INTO $tableName2 VALUES ( ?, ? )";
|
|
||||||
for( $t = 200; $t < 209; $t++ )
|
|
||||||
{
|
|
||||||
$stmt = $conn->prepare( $sql );
|
|
||||||
$ts = substr( sha1( $t ),0,5 );
|
|
||||||
$params = array( $t,$ts );
|
|
||||||
$stmt->execute( $params );
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Break connection by getting the session ID and killing it.
|
// Break connection by getting the session ID and killing it.
|
||||||
// Note that breaking a connection and testing reconnection requires a
|
// Note that breaking a connection and testing reconnection requires a
|
||||||
// TCP/IP protocol connection (as opposed to a Shared Memory protocol).
|
// TCP/IP protocol connection (as opposed to a Shared Memory protocol).
|
||||||
function BreakConnection( $conn, $conn_break )
|
function breakConnection($conn, $conn_break)
|
||||||
{
|
{
|
||||||
$stmt1 = $conn->query( "SELECT @@SPID" );
|
$stmt1 = $conn->query("SELECT @@SPID");
|
||||||
$obj = $stmt1->fetch( PDO::FETCH_NUM );
|
$obj = $stmt1->fetch(PDO::FETCH_NUM);
|
||||||
$spid = $obj[0];
|
$spid = $obj[0];
|
||||||
|
|
||||||
$stmt2 = $conn_break->query( "KILL ".$spid );
|
$stmt2 = $conn_break->query("KILL ".$spid);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any databases previously created by GenerateDatabase
|
// Remove any databases previously created by GenerateDatabase
|
||||||
function DropTables( $server, $uid, $pwd, $tableName1, $tableName2 )
|
function dropTables($server, $uid, $pwd, $tableName1, $tableName2)
|
||||||
{
|
{
|
||||||
global $dbName;
|
global $dbName;
|
||||||
|
|
||||||
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd );
|
$conn = new PDO("sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd);
|
||||||
|
|
||||||
$query="IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
|
$query="IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
|
||||||
$stmt=$conn->query( $query );
|
$stmt=$conn->query($query);
|
||||||
|
|
||||||
$query="IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
|
$query="IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
|
||||||
$stmt=$conn->query( $query );
|
$stmt=$conn->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
DropTables( $server, $uid, $pwd, $tableName1, $tableName2 );
|
dropTables($server, $uid, $pwd, $tableName1, $tableName2);
|
||||||
GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2 );
|
generateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test the TNIR keyword with enabled and disabled options and the MultiSubnetFailover keyword with true and false options
|
Test the TNIR keyword with enabled and disabled options and the MultiSubnetFailover keyword with true and false options
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
// The way SYN packets are sent from the host is different depending on the combination of the TNIR and MultiSubnetFailover values
|
// The way SYN packets are sent from the host is different depending on the combination of the TNIR and MultiSubnetFailover values
|
||||||
|
@ -12,23 +12,20 @@ Test the TNIR keyword with enabled and disabled options and the MultiSubnetFailo
|
||||||
// TNIR is enabled by default
|
// TNIR is enabled by default
|
||||||
// MultiSubnetFailover is disabled by default
|
// MultiSubnetFailover is disabled by default
|
||||||
|
|
||||||
require_once("MsSetup.inc");
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
$GLOBALS['uid'] = $uid;
|
|
||||||
$GLOBALS['pwd'] = $pwd;
|
|
||||||
$GLOBALS['server'] = $server;
|
|
||||||
|
|
||||||
function test_tnir( $TNIRValue, $MSFValue ) {
|
function test_tnir($TNIRValue, $MSFValue)
|
||||||
|
{
|
||||||
$MSFValueStr = ($MSFValue) ? 'true' : 'false';
|
$MSFValueStr = ($MSFValue) ? 'true' : 'false';
|
||||||
$connectionString = "sqlsrv:Server=$GLOBALS[server]; TransparentNetworkIPResolution=$TNIRValue; MultiSubnetFailover=$MSFValueStr";
|
|
||||||
try {
|
try {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$conn = new PDO($connectionString, $GLOBALS['uid'], $GLOBALS['pwd'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
$conn = connect("TransparentNetworkIPResolution=$TNIRValue; MultiSubnetFailover=$MSFValueStr;");
|
||||||
|
|
||||||
echo "Connection successful with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
echo "Connection successful with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
||||||
$connect_time = round(microtime(true) - $start, 2);
|
$connect_time = round(microtime(true) - $start, 2);
|
||||||
echo "Time to connect is $connect_time sec.\n\n";
|
echo "Time to connect is $connect_time sec.\n\n";
|
||||||
$conn = NULL;
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch(PDOException $e) {
|
|
||||||
echo "Connection failed with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
echo "Connection failed with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
||||||
print_r($e->errorInfo);
|
print_r($e->errorInfo);
|
||||||
}
|
}
|
||||||
|
@ -57,4 +54,4 @@ Connection successful with TNIR Disabled and MultiSubnetFailover false\.
|
||||||
Time to connect is [0-9]+.?[0-9]* sec\.
|
Time to connect is [0-9]+.?[0-9]* sec\.
|
||||||
|
|
||||||
Connection successful with TNIR Disabled and MultiSubnetFailover true\.
|
Connection successful with TNIR Disabled and MultiSubnetFailover true\.
|
||||||
Time to connect is [0-9]+.?[0-9]* sec\.
|
Time to connect is [0-9]+.?[0-9]* sec\.
|
||||||
|
|
|
@ -3,44 +3,40 @@ Test for inserting and retrieving encrypted data of datetime types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
No PDO::PARAM_ type specified when binding parameters
|
No PDO::PARAM_ type specified when binding parameters
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
|
||||||
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
|
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect();
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
foreach ($dataTypes as $dataType) {
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
|
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
|
||||||
if ( $r === false ) {
|
if ($r === false) {
|
||||||
is_incompatible_types_error( $stmt, $dataType, "default type" );
|
isIncompatibleTypesError($stmt, $dataType, "default type");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
||||||
fetch_all( $conn, $tbname );
|
fetchAll($conn, $tbname);
|
||||||
}
|
}
|
||||||
DropTable( $conn, $tbname );
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,77 +3,62 @@ Test for inserting and retrieving encrypted data of money types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
No PDO::PARAM_ tpe specified when binding parameters
|
No PDO::PARAM_ tpe specified when binding parameters
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
$dataTypes = array("smallmoney", "money");
|
||||||
$dataTypes = array( "smallmoney", "money" );
|
try {
|
||||||
|
//set to ERRMODE_SILENT to compare actual error and expected unsupport money types in encrypted columns error
|
||||||
try
|
$conn = connect('', array(), PDO::ERRMODE_SILENT);
|
||||||
{
|
foreach ($dataTypes as $dataType) {
|
||||||
$conn = ae_connect();
|
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array(new columnMeta($dataType, "c_det", null, "deterministic", true),
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
new columnMeta($dataType, "c_rand", null, "randomized", true));
|
||||||
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
|
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
|
||||||
|
|
||||||
if ( !is_col_enc() )
|
if (!isColEncrypted()) {
|
||||||
{
|
if ($r === false) {
|
||||||
if ( $r === false )
|
|
||||||
{
|
|
||||||
echo "Default type should be compatible with $dataType.\n";
|
echo "Default type should be compatible with $dataType.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql = "SELECT * FROM $tbname";
|
$sql = "SELECT * FROM $tbname";
|
||||||
$stmt = $conn->query( $sql );
|
$stmt = $conn->query($sql);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
if ( $row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1] )
|
if ($row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1]) {
|
||||||
{
|
|
||||||
echo "Incorrect output retrieved for datatype $dataType.\n";
|
echo "Incorrect output retrieved for datatype $dataType.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if ($r === false) {
|
||||||
{
|
if ($stmt->errorInfo()[0] != "22018") {
|
||||||
if ( $r === false )
|
|
||||||
{
|
|
||||||
if ( $stmt->errorInfo()[0] != "22018" )
|
|
||||||
{
|
|
||||||
echo "Incorrect error returned.\n";
|
echo "Incorrect error returned.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "$dataType is not compatible with any type.\n";
|
echo "$dataType is not compatible with any type.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $success )
|
if ($success) {
|
||||||
echo "Test successfully done.\n";
|
echo "Test successfully done.\n";
|
||||||
DropTable( $conn, $tbname );
|
}
|
||||||
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,44 +3,37 @@ Test for inserting and retrieving encrypted data of numeric types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
No PDO::PARAM_ tpe specified when binding parameters
|
No PDO::PARAM_ tpe specified when binding parameters
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
$dataTypes = array("bit", "tinyint", "smallint", "int", "bigint", "decimal(18,5)", "numeric(10,5)", "float", "real");
|
||||||
$dataTypes = array( "bit", "tinyint", "smallint", "int", "bigint", "decimal(18,5)", "numeric(10,5)", "float", "real" );
|
try {
|
||||||
|
$conn = connect();
|
||||||
try
|
foreach ($dataTypes as $dataType) {
|
||||||
{
|
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
|
$stmt = insertRow($conn, $tbname, array( "c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
|
||||||
if ( $r === false ) {
|
if ($r === false) {
|
||||||
is_incompatible_types_error( $stmt, $dataType, "default type" );
|
isIncompatibleTypesError($stmt, $dataType, "default type");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
||||||
fetch_all( $conn, $tbname );
|
fetchAll($conn, $tbname);
|
||||||
}
|
}
|
||||||
DropTable( $conn, $tbname );
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,49 +3,42 @@ Test for inserting and retrieving encrypted data of datetime types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
|
||||||
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
|
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
|
||||||
|
try {
|
||||||
try
|
$conn = connect();
|
||||||
{
|
foreach ($dataTypes as $dataType) {
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// prepare statement for inserting into table
|
// prepare statement for inserting into table
|
||||||
foreach ( $pdoParamTypes as $pdoParamType ) {
|
foreach ($pdoParamTypes as $pdoParamType) {
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
|
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
|
||||||
if ( $r === false )
|
if ($r === false) {
|
||||||
{
|
isIncompatibleTypesError($stmt, $dataType, $pdoParamType);
|
||||||
is_incompatible_types_error( $stmt, $dataType, $pdoParamType );
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
|
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
|
||||||
fetch_all( $conn, $tbname );
|
fetchAll($conn, $tbname);
|
||||||
}
|
}
|
||||||
$conn->query( "TRUNCATE TABLE $tbname" );
|
$conn->query("TRUNCATE TABLE $tbname");
|
||||||
}
|
}
|
||||||
DropTable( $conn, $tbname );
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,84 +3,69 @@ Test for inserting and retrieving encrypted data of money types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
|
||||||
$dataTypes = array( "smallmoney", "money" );
|
$dataTypes = array( "smallmoney", "money" );
|
||||||
|
try {
|
||||||
try
|
//set to ERRMODE_SILENT to compare actual error and expected unsupport money types in encrypted columns error
|
||||||
{
|
$conn = connect('', array(), PDO::ERRMODE_SILENT);
|
||||||
$conn = ae_connect();
|
foreach ($dataTypes as $dataType) {
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array(new ColumnMeta($dataType, "c_det", null, "deterministic", true),
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
new ColumnMeta($dataType, "c_rand", null, "randomized", true));
|
||||||
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// test each PDO::PARAM_ type
|
// test each PDO::PARAM_ type
|
||||||
foreach ( $pdoParamTypes as $pdoParamType ) {
|
foreach ($pdoParamTypes as $pdoParamType) {
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
|
$stmt = insertRow($conn, $tbname, array("c_det" => new BindParamOp(1, (string)$inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, (string)$inputValues[1], $pdoParamType)), "prepareBindParam", $r);
|
||||||
|
|
||||||
|
|
||||||
if ( !is_col_enc() )
|
if (!isColEncrypted()) {
|
||||||
{
|
if ($r === false) {
|
||||||
if ( $r === false )
|
|
||||||
{
|
|
||||||
echo "$pdoParamType should be compatible with $dataType.\n";
|
echo "$pdoParamType should be compatible with $dataType.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql = "SELECT * FROM $tbname";
|
$sql = "SELECT * FROM $tbname";
|
||||||
$stmt = $conn->query( $sql );
|
$stmt = $conn->query($sql);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
if ( ( $row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1] ) && $pdoParamType != "PDO::PARAM_NULL" )
|
if (($row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1]) && $pdoParamType != "PDO::PARAM_NULL") {
|
||||||
{
|
|
||||||
echo "Incorrect output retrieved for datatype $dataType.\n";
|
echo "Incorrect output retrieved for datatype $dataType.\n";
|
||||||
var_dump( $inputValues );
|
var_dump($inputValues);
|
||||||
var_dump( $row );
|
var_dump($row);
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if ($r === false) {
|
||||||
{
|
if ($stmt->errorInfo()[0] != "22018") {
|
||||||
if ( $r === false )
|
|
||||||
{
|
|
||||||
if ( $stmt->errorInfo()[0] != "22018" )
|
|
||||||
{
|
|
||||||
echo "Incorrect error returned.\n";
|
echo "Incorrect error returned.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "$dataType is not compatible with any type.\n";
|
echo "$dataType is not compatible with any type.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$conn->query( "TRUNCATE TABLE $tbname" );
|
$conn->query("TRUNCATE TABLE $tbname");
|
||||||
}
|
}
|
||||||
if ( $success )
|
if ($success) {
|
||||||
echo "Test successfully done.\n";
|
echo "Test successfully done.\n";
|
||||||
DropTable( $conn, $tbname );
|
}
|
||||||
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,49 +3,45 @@ Test for inserting and retrieving encrypted data of numeric types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
|
||||||
$dataTypes = array( "bit", "tinyint", "smallint", "int", "decimal(18,5)", "numeric(10,5)", "float", "real" );
|
$dataTypes = array( "bit", "tinyint", "smallint", "int", "decimal(18,5)", "numeric(10,5)", "float", "real" );
|
||||||
|
try {
|
||||||
try
|
$conn = connect();
|
||||||
{
|
foreach ($dataTypes as $dataType) {
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// test each PDO::PARAM_ type
|
// test each PDO::PARAM_ type
|
||||||
foreach ( $pdoParamTypes as $pdoParamType ) {
|
foreach ($pdoParamTypes as $pdoParamType) {
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
|
if ($dataType == "decimal(18,5)") {
|
||||||
if ( $r === false )
|
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, (string)$inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, (string)$inputValues[1], $pdoParamType)), "prepareBindParam", $r);
|
||||||
{
|
} else {
|
||||||
is_incompatible_types_error( $stmt, $dataType, $pdoParamType );
|
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
|
||||||
}
|
}
|
||||||
else {
|
if ($r === false) {
|
||||||
|
isIncompatibleTypesError($stmt, $dataType, $pdoParamType);
|
||||||
|
} else {
|
||||||
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
|
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
|
||||||
fetch_all( $conn, $tbname );
|
fetchAll($conn, $tbname);
|
||||||
}
|
}
|
||||||
$conn->query( "TRUNCATE TABLE $tbname" );
|
$conn->query("TRUNCATE TABLE $tbname");
|
||||||
}
|
}
|
||||||
DropTable( $conn, $tbname );
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -121,20 +117,20 @@ c_rand: 2147483647
|
||||||
|
|
||||||
Testing decimal(18,5):
|
Testing decimal(18,5):
|
||||||
****PDO param type PDO::PARAM_BOOL is compatible with encrypted decimal(18,5)****
|
****PDO param type PDO::PARAM_BOOL is compatible with encrypted decimal(18,5)****
|
||||||
c_det: -9223372036854.80078
|
c_det: -9223372036854.80000
|
||||||
c_rand: 9223372036854.80078
|
c_rand: 9223372036854.80000
|
||||||
****PDO param type PDO::PARAM_NULL is compatible with encrypted decimal(18,5)****
|
****PDO param type PDO::PARAM_NULL is compatible with encrypted decimal(18,5)****
|
||||||
c_det:
|
c_det:
|
||||||
c_rand:
|
c_rand:
|
||||||
****PDO param type PDO::PARAM_INT is compatible with encrypted decimal(18,5)****
|
****PDO param type PDO::PARAM_INT is compatible with encrypted decimal(18,5)****
|
||||||
c_det: -9223372036854.80078
|
c_det: -9223372036854.80000
|
||||||
c_rand: 9223372036854.80078
|
c_rand: 9223372036854.80000
|
||||||
****PDO param type PDO::PARAM_STR is compatible with encrypted decimal(18,5)****
|
****PDO param type PDO::PARAM_STR is compatible with encrypted decimal(18,5)****
|
||||||
c_det: -9223372036854.80000
|
c_det: -9223372036854.80000
|
||||||
c_rand: 9223372036854.80000
|
c_rand: 9223372036854.80000
|
||||||
****PDO param type PDO::PARAM_LOB is compatible with encrypted decimal(18,5)****
|
****PDO param type PDO::PARAM_LOB is compatible with encrypted decimal(18,5)****
|
||||||
c_det: -9223372036854.80078
|
c_det: -9223372036854.80000
|
||||||
c_rand: 9223372036854.80078
|
c_rand: 9223372036854.80000
|
||||||
|
|
||||||
Testing numeric(10,5):
|
Testing numeric(10,5):
|
||||||
****PDO param type PDO::PARAM_BOOL is compatible with encrypted numeric(10,5)****
|
****PDO param type PDO::PARAM_BOOL is compatible with encrypted numeric(10,5)****
|
||||||
|
|
|
@ -3,50 +3,41 @@ Test for inserting and retrieving encrypted data of string types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
$dataTypes = array("char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)");
|
||||||
$dataTypes = array( "char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)" );
|
try {
|
||||||
|
$conn = connect('', array(), PDO::ERRMODE_SILENT);
|
||||||
try
|
foreach ($dataTypes as $dataType) {
|
||||||
{
|
|
||||||
$conn = ae_connect();
|
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// prepare statement for inserting into table
|
// prepare statement for inserting into table
|
||||||
foreach ( $pdoParamTypes as $pdoParamType ) {
|
foreach ($pdoParamTypes as $pdoParamType) {
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
|
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType),"c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
|
||||||
if ( $r === false )
|
if ($r === false) {
|
||||||
{
|
isIncompatibleTypesError($stmt, $dataType, $pdoParamType);
|
||||||
is_incompatible_types_error( $stmt, $dataType, $pdoParamType );
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
|
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
|
||||||
fetch_all( $conn, $tbname );
|
fetchAll($conn, $tbname);
|
||||||
}
|
}
|
||||||
$conn->query( "TRUNCATE TABLE $tbname" );
|
$conn->query("TRUNCATE TABLE $tbname");
|
||||||
}
|
}
|
||||||
DropTable( $conn, $tbname );
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,73 +3,60 @@ Test for inserting encrypted data and retrieving both encrypted and decrypted da
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Retrieving SQL query contains encrypted filter
|
Retrieving SQL query contains encrypted filter
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
try {
|
||||||
try
|
$conn = connect();
|
||||||
{
|
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
$tbname = 'Patients';
|
$tbname = 'Patients';
|
||||||
$colMetaArr = array( new columnMeta( "int", "PatientId", "IDENTITY(1,1)" ),
|
$colMetaArr = array( new ColumnMeta("int", "PatientId", "IDENTITY(1,1)"),
|
||||||
new columnMeta( "char(11)", "SSN"),
|
new ColumnMeta("char(11)", "SSN"),
|
||||||
new columnMeta( "nvarchar(50)", "FirstName", "NULL" ),
|
new ColumnMeta("nvarchar(50)", "FirstName", "NULL"),
|
||||||
new columnMeta( "nvarchar(50)", "LastName", "NULL"),
|
new ColumnMeta("nvarchar(50)", "LastName", "NULL"),
|
||||||
new columnMeta( "date", "BirthDate", null, "randomized" ));
|
new ColumnMeta("date", "BirthDate", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert a row
|
// insert a row
|
||||||
$SSN = "795-73-9838";
|
$SSN = "795-73-9838";
|
||||||
$inputs = array( "SSN" => $SSN, "FirstName" => "Catherine", "LastName" => "Abel", "BirthDate" => "1996-10-19" );
|
$inputs = array( "SSN" => $SSN, "FirstName" => "Catherine", "LastName" => "Abel", "BirthDate" => "1996-10-19" );
|
||||||
$stmt = insert_row( $conn, $tbname, $inputs );
|
$stmt = insertRow($conn, $tbname, $inputs);
|
||||||
|
|
||||||
echo "Retrieving plaintext data:\n";
|
echo "Retrieving plaintext data:\n";
|
||||||
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname WHERE SSN = ?";
|
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname WHERE SSN = ?";
|
||||||
$stmt = $conn->prepare( $selectSql );
|
$stmt = $conn->prepare($selectSql);
|
||||||
$stmt->bindParam( 1, $SSN );
|
$stmt->bindParam(1, $SSN);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC );
|
$decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
foreach ( $decrypted_row as $key => $value )
|
foreach ($decrypted_row as $key => $value) {
|
||||||
{
|
|
||||||
print "$key: $value\n";
|
print "$key: $value\n";
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
echo "\nChecking ciphertext data:\n";
|
echo "\nChecking ciphertext data:\n";
|
||||||
if ( is_col_enc() )
|
if (isColEncrypted()) {
|
||||||
{
|
try {
|
||||||
try
|
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
{
|
|
||||||
$conn1 = ae_connect( null, null, true );
|
|
||||||
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname";
|
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname";
|
||||||
$stmt = $conn1->query( $selectSql );
|
$stmt = $conn1->query($selectSql);
|
||||||
$encrypted_row = $stmt->fetch( PDO::FETCH_ASSOC );
|
$encrypted_row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
foreach ( $encrypted_row as $key => $value )
|
foreach ($encrypted_row as $key => $value) {
|
||||||
{
|
if (ctype_print($value)) {
|
||||||
if ( ctype_print( $value ))
|
|
||||||
print "Error: expected a binary array for $key\n";
|
print "Error: expected a binary array for $key\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn1 );
|
unset($conn1);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dropTable($conn, $tbname);
|
||||||
DropTable( $conn, $tbname );
|
unset($conn);
|
||||||
unset( $conn );
|
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
|
@ -1,80 +1,64 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test for inserting encrypted fixed size types data and retrieve both encrypted and decrypted data
|
Test for inserting encrypted fixed size types data and retrieve both encrypted and decrypted data
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
try {
|
||||||
try
|
$conn = connect();
|
||||||
{
|
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
$tbname = 'FixedSizeAnalysis';
|
$tbname = 'FixedSizeAnalysis';
|
||||||
$colMetaArr = array( new columnMeta( "tinyint", "TinyIntData" ),
|
$colMetaArr = array("TinyIntData" => "tinyint",
|
||||||
new columnMeta( "smallint", "SmallIntData" ),
|
"SmallIntData" => "smallint",
|
||||||
new columnMeta( "int", "IntData" ),
|
"IntData" => "int",
|
||||||
new columnMeta( "bigint", "BigIntData" ),
|
"BigIntData" => "bigint",
|
||||||
new columnMeta( "decimal(38,0)", "DecimalData" ),
|
"DecimalData" => "decimal(18,0)",
|
||||||
new columnMeta( "bit", "BitData" ),
|
"BitData" => "bit",
|
||||||
new columnMeta( "datetime", "DateTimeData" ),
|
"DateTimeData" => "datetime",
|
||||||
new columnMeta( "datetime2", "DateTime2Data" ));
|
"DateTime2Data" => "datetime2");
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert a row
|
|
||||||
$inputs = array( "TinyIntData" => 255,
|
|
||||||
"SmallIntData" => 32767,
|
|
||||||
"IntData" => 2147483647,
|
|
||||||
"BigIntData" => 92233720368547,
|
|
||||||
"DecimalData" => 79228162514264,
|
|
||||||
"BitData" => true,
|
|
||||||
"DateTimeData" => '9999-12-31 23:59:59.997',
|
|
||||||
"DateTime2Data" => '9999-12-31 23:59:59.9999999');
|
|
||||||
$paramOptions = array( new bindParamOption( 4, "PDO::PARAM_INT" ) );
|
|
||||||
$r;
|
|
||||||
$stmt = insert_row( $conn, $tbname, $inputs, $r, "prepareBindParam", $paramOptions );
|
|
||||||
|
|
||||||
print "Decrypted values:\n";
|
|
||||||
fetch_all( $conn, $tbname );
|
|
||||||
|
|
||||||
unset( $stmt );
|
// insert a row
|
||||||
}
|
$inputs = array( "TinyIntData" => 255,
|
||||||
catch( PDOException $e )
|
"SmallIntData" => 32767,
|
||||||
{
|
"IntData" => 2147483647,
|
||||||
|
"BigIntData" => 92233720368547,
|
||||||
|
"DecimalData" => 79228162514264,
|
||||||
|
"BitData" => true,
|
||||||
|
"DateTimeData" => '9999-12-31 23:59:59.997',
|
||||||
|
"DateTime2Data" => '9999-12-31 23:59:59.9999999');
|
||||||
|
//$paramOptions = array( new bindParamOption(4, "PDO::PARAM_INT") );
|
||||||
|
$r;
|
||||||
|
$stmt = insertRow($conn, $tbname, $inputs, "prepareBindParam", $r);
|
||||||
|
|
||||||
|
print "Decrypted values:\n";
|
||||||
|
fetchAll($conn, $tbname);
|
||||||
|
unset($stmt);
|
||||||
|
} catch (PDOException $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
if ( is_col_enc() )
|
if (isColEncrypted()) {
|
||||||
{
|
try {
|
||||||
try
|
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
{
|
|
||||||
$conn1 = ae_connect( null, null, true );
|
|
||||||
|
|
||||||
$selectSql = "SELECT * FROM $tbname";
|
$selectSql = "SELECT * FROM $tbname";
|
||||||
$stmt = $conn1->query( $selectSql );
|
$stmt = $conn1->query($selectSql);
|
||||||
$encrypted_row = $stmt->fetch( PDO::FETCH_ASSOC );
|
$encrypted_row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
foreach ( $encrypted_row as $key => $value )
|
foreach ($encrypted_row as $key => $value) {
|
||||||
{
|
if (ctype_print($value)) {
|
||||||
if ( ctype_print( $value ))
|
|
||||||
{
|
|
||||||
print "Error: expected a binary array for $key\n";
|
print "Error: expected a binary array for $key\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($stmt);
|
||||||
unset( $stmt );
|
unset($conn1);
|
||||||
unset( $conn1 );
|
} catch (PDOException $e) {
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dropTable($conn, $tbname);
|
||||||
DropTable( $conn, $tbname );
|
unset($conn);
|
||||||
unset( $conn );
|
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -87,4 +71,4 @@ DecimalData: 79228162514264
|
||||||
BitData: 1
|
BitData: 1
|
||||||
DateTimeData: 9999-12-31 23:59:59.997
|
DateTimeData: 9999-12-31 23:59:59.997
|
||||||
DateTime2Data: 9999-12-31 23:59:59.9999999
|
DateTime2Data: 9999-12-31 23:59:59.9999999
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -1,79 +1,60 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test for inserting encrypted nvarchar data of variable lengths and retrieving encrypted and decrypted data
|
Test for inserting encrypted nvarchar data of variable lengths and retrieving encrypted and decrypted data
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
$testPass = true;
|
$testPass = true;
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect();
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
$tbname = 'NVarcharAnalysis';
|
$tbname = 'NVarcharAnalysis';
|
||||||
$colMetaArr = array( new columnMeta( "int", "CharCount", "IDENTITY(0,1)" ), new columnMeta( "nvarchar(1000)" ));
|
$colMetaArr = array( new ColumnMeta("int", "CharCount", "IDENTITY(0,1)"), new columnMeta("nvarchar(1000)"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert 1000 rows
|
// insert 1000 rows
|
||||||
for ( $i = 0; $i < 1000; $i++ )
|
for ($i = 0; $i < 1000; $i++) {
|
||||||
{
|
$data = str_repeat("*", $i);
|
||||||
$data = str_repeat( "*", $i );
|
$stmt = insertRow($conn, $tbname, array(getDefaultColName("nvarchar(1000)") => $data));
|
||||||
$stmt = insert_row( $conn, $tbname, array( get_default_colname( "nvarchar(1000)" ) => $data ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectSql = "SELECT * FROM $tbname";
|
$selectSql = "SELECT * FROM $tbname";
|
||||||
$stmt = $conn->query( $selectSql );
|
$stmt = $conn->query($selectSql);
|
||||||
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
|
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
{
|
if ($decrypted_row['CharCount'] != strlen($decrypted_row[getDefaultColName("nvarchar(1000)")])) {
|
||||||
if ( $decrypted_row[ 'CharCount' ] != strlen( $decrypted_row[ get_default_colname( "nvarchar(1000)" ) ] ))
|
$rowInd = $decrypted_row['CharCount'] + 1;
|
||||||
{
|
|
||||||
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
|
|
||||||
echo "Failed to decrypted at row $rowInd\n";
|
echo "Failed to decrypted at row $rowInd\n";
|
||||||
$testPass = false;
|
$testPass = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
if ( is_col_enc() )
|
if (isColEncrypted()) {
|
||||||
{
|
try {
|
||||||
try
|
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
{
|
$stmt = $conn1->query($selectSql);
|
||||||
$conn1 = ae_connect( null, null, true );
|
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$stmt = $conn1->query( $selectSql );
|
if ($decrypted_row['CharCount'] == strlen($decrypted_row[getDefaultColName("nvarchar(1000)")])) {
|
||||||
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
|
|
||||||
{
|
|
||||||
if ( $decrypted_row[ 'CharCount' ] == strlen( $decrypted_row[ get_default_colname( "nvarchar(1000)" ) ] ))
|
|
||||||
{
|
|
||||||
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
|
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
|
||||||
echo "Failed to encrypted at row $rowInd\n";
|
echo "Failed to encrypted at row $rowInd\n";
|
||||||
$testPass = false;
|
$testPass = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($stmt);
|
||||||
unset( $stmt );
|
unset($conn1);
|
||||||
unset( $conn1 );
|
} catch (PDOException $e) {
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dropTable($conn, $tbname);
|
||||||
DropTable( $conn, $tbname );
|
unset($conn);
|
||||||
unset( $conn );
|
if ($testPass) {
|
||||||
|
|
||||||
if ( $testPass ) {
|
|
||||||
echo "Test successfully done.\n";
|
echo "Test successfully done.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test successfully done.
|
Test successfully done.
|
||||||
|
|
|
@ -1,78 +1,60 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test for inserting encrypted varchar data of variable lengths and retrieving encrypted and decrypted data
|
Test for inserting encrypted varchar data of variable lengths and retrieving encrypted and decrypted data
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
$testPass = true;
|
$testPass = true;
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect();
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
$tbname = 'VarcharAnalysis';
|
$tbname = 'VarcharAnalysis';
|
||||||
$colMetaArr = array( new columnMeta( "int", "CharCount", "IDENTITY(0,1)" ), new columnMeta( "varchar(1000)" ));
|
$colMetaArr = array( new ColumnMeta("int", "CharCount", "IDENTITY(0,1)"), new ColumnMeta("varchar(1000)"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert 1000 rows
|
// insert 1000 rows
|
||||||
for( $i = 0; $i < 1000; $i++ )
|
for ($i = 0; $i < 1000; $i++) {
|
||||||
{
|
$data = str_repeat("*", $i);
|
||||||
$data = str_repeat( "*", $i );
|
$stmt = insertRow($conn, $tbname, array(getDefaultColname("varchar(1000)") => $data));
|
||||||
$stmt = insert_row( $conn, $tbname, array( get_default_colname( "varchar(1000)" ) => $data ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectSql = "SELECT * FROM $tbname";
|
$selectSql = "SELECT * FROM $tbname";
|
||||||
$stmt = $conn->query( $selectSql );
|
$stmt = $conn->query($selectSql);
|
||||||
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
|
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
{
|
if ($decrypted_row['CharCount'] != strlen($decrypted_row[getDefaultColname("varchar(1000)")])) {
|
||||||
if ( $decrypted_row[ 'CharCount' ] != strlen( $decrypted_row[ get_default_colname( "varchar(1000)" ) ] ))
|
$rowInd = $decrypted_row['CharCount'] + 1;
|
||||||
{
|
|
||||||
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
|
|
||||||
echo "Failed to decrypted at row $rowInd\n";
|
echo "Failed to decrypted at row $rowInd\n";
|
||||||
$testPass = false;
|
$testPass = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
if ( is_col_enc() )
|
if (isColEncrypted()) {
|
||||||
{
|
try {
|
||||||
try
|
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
{
|
$stmt = $conn1->query($selectSql);
|
||||||
$conn1 = ae_connect( null, null, true );
|
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$stmt = $conn1->query( $selectSql );
|
if ($decrypted_row['CharCount'] == strlen($decrypted_row[getDefaultColname("varchar(1000)")])) {
|
||||||
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
|
|
||||||
{
|
|
||||||
if ( $decrypted_row[ 'CharCount' ] == strlen( $decrypted_row[ get_default_colname( "varchar(1000)" ) ] ))
|
|
||||||
{
|
|
||||||
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
|
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
|
||||||
echo "Failed to encrypted at row $rowInd\n";
|
echo "Failed to encrypted at row $rowInd\n";
|
||||||
$testPass = false;
|
$testPass = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($stmt);
|
||||||
unset( $stmt );
|
unset($conn1);
|
||||||
unset( $conn1 );
|
} catch (PDOException $e) {
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dropTable($conn, $tbname);
|
||||||
DropTable( $conn, $tbname );
|
unset($conn);
|
||||||
unset( $conn );
|
if ($testPass) {
|
||||||
|
|
||||||
if ( $testPass ) {
|
|
||||||
echo "Test successfully done.\n";
|
echo "Test successfully done.\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Test successfully done.
|
Test successfully done.
|
||||||
|
|
|
@ -3,44 +3,37 @@ Test for inserting and retrieving encrypted data of string types
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
No PDO::PARAM_ type specified when binding parameters
|
No PDO::PARAM_ type specified when binding parameters
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
include 'AEData.inc';
|
require_once("AEData.inc");
|
||||||
|
$dataTypes = array("char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)");
|
||||||
$dataTypes = array( "char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)" );
|
try {
|
||||||
|
$conn = connect();
|
||||||
try
|
foreach ($dataTypes as $dataType) {
|
||||||
{
|
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
foreach ( $dataTypes as $dataType ) {
|
|
||||||
echo "\nTesting $dataType:\n";
|
echo "\nTesting $dataType:\n";
|
||||||
|
|
||||||
// create table
|
// create table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
|
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// insert a row
|
// insert a row
|
||||||
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
|
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
|
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
|
||||||
if ( $r === false ) {
|
if ($r === false) {
|
||||||
is_incompatible_types_error( $stmt, $dataType, "default type" );
|
isIncompatibleTypesError($stmt, $dataType, "default type");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
||||||
fetch_all( $conn, $tbname );
|
fetchAll($conn, $tbname);
|
||||||
}
|
}
|
||||||
DropTable( $conn, $tbname );
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
unset( $stmt );
|
unset($stmt);
|
||||||
unset( $conn );
|
unset($conn);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,84 +1,78 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test for binding output params for encrypted data for all types
|
Test for binding output params for encrypted data for all types
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
$conn = connect();
|
||||||
$conn = ae_connect();
|
|
||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
$tbname = GetTempTableName( "", false );
|
$tbname = getTableName();
|
||||||
$colMetaArr = array( new columnMeta( "int", "c1_int" ),
|
$colMetaArr = array("c1_int" => "int",
|
||||||
new columnMeta( "smallint", "c2_smallint" ),
|
"c2_smallint" => "smallint",
|
||||||
new columnMeta( "tinyint", "c3_tinyint" ),
|
"c3_tinyint" => "tinyint",
|
||||||
new columnMeta( "bit", "c4_bit" ),
|
"c4_bit" => "bit",
|
||||||
new columnMeta( "bigint", "c5_bigint" ),
|
"c5_bigint" => "bigint",
|
||||||
new columnMeta( "decimal(18,5)", "c6_decimal" ),
|
"c6_decimal" => "decimal(18,5)",
|
||||||
new columnMeta( "numeric(10,5)", "c7_numeric" ),
|
"c7_numeric" => "numeric(10,5)",
|
||||||
new columnMeta( "float", "c8_float" ),
|
"c8_float" => "float",
|
||||||
new columnMeta( "real", "c9_real" ),
|
"c9_real" => "real",
|
||||||
new columnMeta( "date", "c10_date" ),
|
"c10_date" => "date",
|
||||||
new columnMeta( "datetime", "c11_datetime" ),
|
"c11_datetime" => "datetime",
|
||||||
new columnMeta( "datetime2", "c12_datetime2" ),
|
"c12_datetime2" => "datetime2",
|
||||||
new columnMeta( "datetimeoffset", "c13_datetimeoffset" ),
|
"c13_datetimeoffset" => "datetimeoffset",
|
||||||
new columnMeta( "time", "c14_time" ),
|
"c14_time" => "time",
|
||||||
new columnMeta( "char(5)", "c15_char" ),
|
"c15_char" => "char(5)",
|
||||||
new columnMeta( "varchar(max)", "c16_varchar" ),
|
"c16_varchar" => "varchar(max)",
|
||||||
new columnMeta( "nchar(5)", "c17_nchar" ),
|
"c17_nchar" => "nchar(5)",
|
||||||
new columnMeta( "nvarchar(max)", "c18_nvarchar" ));
|
"c18_nvarchar" => "nvarchar(max)");
|
||||||
create_table( $conn, $tbname, $colMetaArr );
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
// Create a Store Procedure
|
// Create a Store Procedure
|
||||||
$spname = 'selectAllColumns';
|
$spname = 'selectAllColumns';
|
||||||
$spSql = "CREATE PROCEDURE $spname (
|
$spSql = "CREATE PROCEDURE $spname (
|
||||||
@c1_int int OUTPUT, @c2_smallint smallint OUTPUT,
|
@c1_int int OUTPUT, @c2_smallint smallint OUTPUT,
|
||||||
@c3_tinyint tinyint OUTPUT, @c4_bit bit OUTPUT,
|
@c3_tinyint tinyint OUTPUT, @c4_bit bit OUTPUT,
|
||||||
@c5_bigint bigint OUTPUT, @c6_decimal decimal(18,5) OUTPUT,
|
@c5_bigint bigint OUTPUT, @c6_decimal decimal(18,5) OUTPUT,
|
||||||
@c7_numeric numeric(10,5) OUTPUT, @c8_float float OUTPUT,
|
@c7_numeric numeric(10,5) OUTPUT, @c8_float float OUTPUT,
|
||||||
@c9_real real OUTPUT, @c10_date date OUTPUT,
|
@c9_real real OUTPUT, @c10_date date OUTPUT,
|
||||||
@c11_datetime datetime OUTPUT, @c12_datetime2 datetime2 OUTPUT,
|
@c11_datetime datetime OUTPUT, @c12_datetime2 datetime2 OUTPUT,
|
||||||
@c13_datetimeoffset datetimeoffset OUTPUT, @c14_time time OUTPUT,
|
@c13_datetimeoffset datetimeoffset OUTPUT, @c14_time time OUTPUT,
|
||||||
@c15_char char(5) OUTPUT, @c16_varchar varchar(max) OUTPUT,
|
@c15_char char(5) OUTPUT, @c16_varchar varchar(max) OUTPUT,
|
||||||
@c17_nchar nchar(5) OUTPUT, @c18_nvarchar nvarchar(max) OUTPUT) AS
|
@c17_nchar nchar(5) OUTPUT, @c18_nvarchar nvarchar(max) OUTPUT) AS
|
||||||
SELECT @c1_int = c1_int, @c2_smallint = c2_smallint,
|
SELECT @c1_int = c1_int, @c2_smallint = c2_smallint,
|
||||||
@c3_tinyint = c3_tinyint, @c4_bit = c4_bit,
|
@c3_tinyint = c3_tinyint, @c4_bit = c4_bit,
|
||||||
@c5_bigint = c5_bigint, @c6_decimal = c6_decimal,
|
@c5_bigint = c5_bigint, @c6_decimal = c6_decimal,
|
||||||
@c7_numeric = c7_numeric, @c8_float = c8_float,
|
@c7_numeric = c7_numeric, @c8_float = c8_float,
|
||||||
@c9_real = c9_real, @c10_date = c10_date,
|
@c9_real = c9_real, @c10_date = c10_date,
|
||||||
@c11_datetime = c11_datetime, @c12_datetime2 = c12_datetime2,
|
@c11_datetime = c11_datetime, @c12_datetime2 = c12_datetime2,
|
||||||
@c13_datetimeoffset = c13_datetimeoffset, @c14_time = c14_time,
|
@c13_datetimeoffset = c13_datetimeoffset, @c14_time = c14_time,
|
||||||
@c15_char = c15_char, @c16_varchar = c16_varchar,
|
@c15_char = c15_char, @c16_varchar = c16_varchar,
|
||||||
@c17_nchar = c17_nchar, @c18_nvarchar = c18_nvarchar
|
@c17_nchar = c17_nchar, @c18_nvarchar = c18_nvarchar
|
||||||
FROM $tbname";
|
FROM $tbname";
|
||||||
$conn->query( $spSql );
|
$conn->query($spSql);
|
||||||
|
|
||||||
// Insert data
|
// Insert data
|
||||||
$inputs = array( "c1_int" => 2147483647,
|
$inputs = array( "c1_int" => 2147483647,
|
||||||
"c2_smallint" => 32767,
|
"c2_smallint" => 32767,
|
||||||
"c3_tinyint" => 255,
|
"c3_tinyint" => 255,
|
||||||
"c4_bit" => 1,
|
"c4_bit" => 1,
|
||||||
"c5_bigint" => 922337203685479936,
|
"c5_bigint" => 922337203685479936,
|
||||||
"c6_decimal" => 9223372036854.80000,
|
"c6_decimal" => 9223372036854.80000,
|
||||||
"c7_numeric" => 21474.83647,
|
"c7_numeric" => 21474.83647,
|
||||||
"c8_float" => 9223372036.8548,
|
"c8_float" => 9223372036.8548,
|
||||||
"c9_real" => 2147.483,
|
"c9_real" => 2147.483,
|
||||||
"c10_date" => '9999-12-31',
|
"c10_date" => '9999-12-31',
|
||||||
"c11_datetime" => '9999-12-31 23:59:59.997',
|
"c11_datetime" => '9999-12-31 23:59:59.997',
|
||||||
"c12_datetime2" => '9999-12-31 23:59:59.9999999',
|
"c12_datetime2" => '9999-12-31 23:59:59.9999999',
|
||||||
"c13_datetimeoffset" => '9999-12-31 23:59:59.9999999 +14:00',
|
"c13_datetimeoffset" => '9999-12-31 23:59:59.9999999 +14:00',
|
||||||
"c14_time" => '23:59:59.9999999',
|
"c14_time" => '23:59:59.9999999',
|
||||||
"c15_char" => 'th, n',
|
"c15_char" => 'th, n',
|
||||||
"c16_varchar" => 'This large row size can cause errors (such as error 512) during some normal operations, such as a clustered index key update, or sorts of the full column set, which users cannot anticipate until performing an operation.',
|
"c16_varchar" => 'This large row size can cause errors (such as error 512) during some normal operations, such as a clustered index key update, or sorts of the full column set, which users cannot anticipate until performing an operation.',
|
||||||
"c17_nchar" => 'th Un',
|
"c17_nchar" => 'th Un',
|
||||||
"c18_nvarchar" => 'When prefixing a string constant with the letter N, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type (4,000).' );
|
"c18_nvarchar" => 'When prefixing a string constant with the letter N, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type (4,000).' );
|
||||||
$paramOptions = array( new bindParamOption( 5, "PDO::PARAM_INT" ) );
|
|
||||||
$r;
|
$r;
|
||||||
$stmt = insert_row( $conn, $tbname, $inputs, $r, "prepareBindParam", $paramOptions );
|
$stmt = insertRow($conn, $tbname, $inputs, null, $r);
|
||||||
|
|
||||||
// Call store procedure
|
// Call store procedure
|
||||||
$outSql = get_callProcSql_placeholders( $spname, count( $inputs ));
|
$outSql = getCallProcSqlPlaceholders($spname, count($inputs));
|
||||||
$intOut = 0;
|
$intOut = 0;
|
||||||
$smallintOut = 0;
|
$smallintOut = 0;
|
||||||
$tinyintOut = 0;
|
$tinyintOut = 0;
|
||||||
|
@ -97,7 +91,7 @@ $charOut = '';
|
||||||
$varcharOut = '';
|
$varcharOut = '';
|
||||||
$ncharOut = '';
|
$ncharOut = '';
|
||||||
$nvarcharOut = '';
|
$nvarcharOut = '';
|
||||||
$stmt = $conn->prepare( $outSql );
|
$stmt = $conn->prepare($outSql);
|
||||||
$stmt->bindParam(1, $intOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
|
$stmt->bindParam(1, $intOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
|
||||||
$stmt->bindParam(2, $smallintOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
|
$stmt->bindParam(2, $smallintOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
|
||||||
$stmt->bindParam(3, $tinyintOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
|
$stmt->bindParam(3, $tinyintOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
|
||||||
|
@ -117,31 +111,28 @@ $stmt->bindParam(16, $varcharOut, PDO::PARAM_STR, 2048);
|
||||||
$stmt->bindParam(17, $ncharOut, PDO::PARAM_STR, 2048);
|
$stmt->bindParam(17, $ncharOut, PDO::PARAM_STR, 2048);
|
||||||
$stmt->bindParam(18, $nvarcharOut, PDO::PARAM_STR, 2048);
|
$stmt->bindParam(18, $nvarcharOut, PDO::PARAM_STR, 2048);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
print("intOut: " . $intOut . "\n");
|
||||||
print ( "intOut: " . $intOut . "\n" );
|
print("smallintOut: " . $smallintOut . "\n");
|
||||||
print ( "smallintOut: " . $smallintOut . "\n" );
|
print("tinyintOut: " . $tinyintOut . "\n");
|
||||||
print ( "tinyintOut: " . $tinyintOut . "\n" );
|
print("bitOut: " . $bitOut . "\n");
|
||||||
print ( "bitOut: " . $bitOut . "\n" );
|
print("bigintOut: " . $bigintOut . "\n");
|
||||||
print ( "bigintOut: " . $bigintOut . "\n" );
|
print("decimalOut: " . $decimalOut . "\n");
|
||||||
print ( "decimalOut: " . $decimalOut . "\n" );
|
print("numericOut: " . $numericOut . "\n");
|
||||||
print ( "numericOut: " . $numericOut . "\n" );
|
print("floatOut: " . $floatOut . "\n");
|
||||||
print ( "floatOut: " . $floatOut . "\n" );
|
print("realOut: " . $realOut . "\n");
|
||||||
print ( "realOut: " . $realOut . "\n" );
|
print("dateOut: " . $dateOut . "\n");
|
||||||
print ( "dateOut: " . $dateOut . "\n" );
|
print("datetimeOut: " . $datetimeOut . "\n");
|
||||||
print ( "datetimeOut: " . $datetimeOut . "\n" );
|
print("datetime2Out: " . $datetime2Out . "\n");
|
||||||
print ( "datetime2Out: " . $datetime2Out . "\n" );
|
print("datetimeoffsetOut: " . $datetimeoffsetOut . "\n");
|
||||||
print ( "datetimeoffsetOut: " . $datetimeoffsetOut . "\n" );
|
print("timeOut: " . $timeOut . "\n");
|
||||||
print ( "timeOut: " . $timeOut . "\n" );
|
print("charOut: " . $charOut . "\n");
|
||||||
print ( "charOut: " . $charOut . "\n" );
|
print("varcharOut: " . $varcharOut . "\n");
|
||||||
print ( "varcharOut: " . $varcharOut . "\n" );
|
print("ncharOut: " . $ncharOut . "\n");
|
||||||
print ( "ncharOut: " . $ncharOut . "\n" );
|
print("nvarcharOut: " . $nvarcharOut . "\n");
|
||||||
print ( "nvarcharOut: " . $nvarcharOut . "\n" );
|
dropProc($conn, $spname);
|
||||||
|
dropTable($conn, $tbname);
|
||||||
$conn->query( "DROP PROCEDURE $spname" );
|
unset($stmt);
|
||||||
$conn->query( "DROP TABLE $tbname" );
|
unset($conn);
|
||||||
unset( $stmt );
|
|
||||||
unset( $conn );
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTREGEX--
|
--EXPECTREGEX--
|
||||||
intOut: 2147483647
|
intOut: 2147483647
|
||||||
|
@ -161,4 +152,4 @@ timeOut: 23:59:59\.9999999
|
||||||
charOut: th\, n
|
charOut: th\, n
|
||||||
varcharOut: This large row size can cause errors \(such as error 512\) during some normal operations\, such as a clustered index key update\, or sorts of the full column set\, which users cannot anticipate until performing an operation\.
|
varcharOut: This large row size can cause errors \(such as error 512\) during some normal operations\, such as a clustered index key update\, or sorts of the full column set\, which users cannot anticipate until performing an operation\.
|
||||||
ncharOut: th Un
|
ncharOut: th Un
|
||||||
nvarcharOut: When prefixing a string constant with the letter N\, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type \(4,000\).
|
nvarcharOut: When prefixing a string constant with the letter N\, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type \(4,000\).
|
||||||
|
|
|
@ -14,6 +14,7 @@ createTable($conn, $tbname, array("c1_bigint" => "bigint"));
|
||||||
|
|
||||||
// Create a Stored Procedure
|
// Create a Stored Procedure
|
||||||
$spname = "selectBigint";
|
$spname = "selectBigint";
|
||||||
|
dropProc($conn, $spname);
|
||||||
$spSql = "CREATE PROCEDURE $spname (@c1_bigint bigint OUTPUT) AS
|
$spSql = "CREATE PROCEDURE $spname (@c1_bigint bigint OUTPUT) AS
|
||||||
SELECT @c1_bigint = c1_bigint FROM $tbname";
|
SELECT @c1_bigint = c1_bigint FROM $tbname";
|
||||||
$conn->query($spSql);
|
$conn->query($spSql);
|
||||||
|
|
|
@ -14,6 +14,7 @@ createTable($conn, $tbname, array("c1_bool" => "int"));
|
||||||
|
|
||||||
// Create a Stored Procedure
|
// Create a Stored Procedure
|
||||||
$spname = "selectBool";
|
$spname = "selectBool";
|
||||||
|
dropProc($conn, $spname);
|
||||||
$spSql = "CREATE PROCEDURE $spname (@c1_bool int OUTPUT) AS
|
$spSql = "CREATE PROCEDURE $spname (@c1_bool int OUTPUT) AS
|
||||||
SELECT @c1_bool = c1_bool FROM $tbname";
|
SELECT @c1_bool = c1_bool FROM $tbname";
|
||||||
$conn->query($spSql);
|
$conn->query($spSql);
|
||||||
|
|
|
@ -17,218 +17,194 @@ non-MARS connection. This should fail too.
|
||||||
// when exiting the helper method? Do the associated cursors remain active? It is an
|
// when exiting the helper method? Do the associated cursors remain active? It is an
|
||||||
// unnecessary complication, so I have left the code like this.
|
// unnecessary complication, so I have left the code like this.
|
||||||
|
|
||||||
require_once( "break_pdo.php" );
|
require_once("break_pdo.php");
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
$conn_break = new PDO( "sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd );
|
$conn_break = connect();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Part 1
|
// Part 1
|
||||||
// Expected to successfully execute second query because buffered cursor for
|
// Expected to successfully execute second query because buffered cursor for
|
||||||
// first query means connection is idle when broken
|
// first query means connection is idle when broken
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$connectionInfo = "ConnectRetryCount = 10; ConnectRetryInterval = 10;";
|
$connectionInfo = "ConnectRetryCount = 10; ConnectRetryInterval = 10;";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
// TODO: Idle connection resiliency does not work with Column Encryption at this point
|
||||||
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ; $connectionInfo", $uid, $pwd );
|
// Do not connect with ColumnEncryption for now
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
$conn = connect($connectionInfo, array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Could not connect.\n";
|
echo "Could not connect.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$query1 = "SELECT * FROM $tableName1";
|
$query1 = "SELECT * FROM $tableName1";
|
||||||
|
try {
|
||||||
try
|
$stmt1 = $conn->prepare($query1, array( PDO::ATTR_CURSOR=> PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE=> PDO::SQLSRV_CURSOR_BUFFERED ));
|
||||||
{
|
if ($stmt1->execute()) {
|
||||||
$stmt1 = $conn->prepare( $query1, array( PDO::ATTR_CURSOR=> PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE=> PDO::SQLSRV_CURSOR_BUFFERED ) );
|
echo "Statement 1 successful.\n";
|
||||||
if ( $stmt1->execute() ) echo "Statement 1 successful.\n";
|
}
|
||||||
|
|
||||||
$rowcount = $stmt1->rowCount();
|
$rowcount = $stmt1->rowCount();
|
||||||
echo $rowcount." rows in result set.\n";
|
echo $rowcount." rows in result set.\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Error executing statement 1.\n";
|
echo "Error executing statement 1.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakConnection( $conn, $conn_break );
|
breakConnection($conn, $conn_break);
|
||||||
|
|
||||||
$query2 = "SELECT * FROM $tableName2";
|
$query2 = "SELECT * FROM $tableName2";
|
||||||
|
try {
|
||||||
try
|
$stmt2 = $conn->prepare($query2, array( PDO::ATTR_CURSOR=> PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE=> PDO::SQLSRV_CURSOR_BUFFERED ));
|
||||||
{
|
if ($stmt2->execute()) {
|
||||||
$stmt2 = $conn->prepare( $query2, array( PDO::ATTR_CURSOR=> PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE=> PDO::SQLSRV_CURSOR_BUFFERED ) );
|
echo "Statement 2 successful.\n";
|
||||||
if ( $stmt2->execute() ) echo "Statement 2 successful.\n";
|
}
|
||||||
|
|
||||||
$rowcount = $stmt2->rowCount();
|
$rowcount = $stmt2->rowCount();
|
||||||
echo $rowcount." rows in result set.\n";
|
echo $rowcount." rows in result set.\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Error executing statement 2.\n";
|
echo "Error executing statement 2.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = null;
|
unset($conn);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Part 2
|
// Part 2
|
||||||
// Expected to successfully execute second query because first statement is
|
// Expected to successfully execute second query because first statement is
|
||||||
// freed before breaking connection
|
// freed before breaking connection
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect($connectionInfo, array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ; $connectionInfo", $uid, $pwd );
|
} catch (PDOException $e) {
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Could not connect.\n";
|
echo "Could not connect.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$query1 = "SELECT * FROM $tableName1";
|
$query1 = "SELECT * FROM $tableName1";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$stmt3 = $conn->query($query1);
|
||||||
$stmt3 = $conn->query( $query1 );
|
if ($stmt3) {
|
||||||
if ( $stmt3 ) echo "Statement 3 successful.\n";
|
echo "Statement 3 successful.\n";
|
||||||
|
}
|
||||||
|
|
||||||
$rowcount = $stmt3->rowCount();
|
$rowcount = $stmt3->rowCount();
|
||||||
echo $rowcount." rows in result set.\n";
|
echo $rowcount." rows in result set.\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Error executing statement 3.\n";
|
echo "Error executing statement 3.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt3 = null;
|
unset($stmt3);
|
||||||
|
|
||||||
BreakConnection( $conn, $conn_break );
|
breakConnection($conn, $conn_break);
|
||||||
|
|
||||||
$query2 = "SELECT * FROM $tableName2";
|
$query2 = "SELECT * FROM $tableName2";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$stmt4 = $conn->query($query2);
|
||||||
$stmt4 = $conn->query( $query2 );
|
if ($stmt4) {
|
||||||
if ( $stmt4 ) echo "Statement 4 successful.\n";
|
echo "Statement 4 successful.\n";
|
||||||
|
}
|
||||||
|
|
||||||
$rowcount = $stmt4->rowCount();
|
$rowcount = $stmt4->rowCount();
|
||||||
echo $rowcount." rows in result set.\n";
|
echo $rowcount." rows in result set.\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Error executing statement 4.\n";
|
echo "Error executing statement 4.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = null;
|
unset($conn);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Part 3
|
// Part 3
|
||||||
// Expected to fail executing second query because default cursor for first
|
// Expected to fail executing second query because default cursor for first
|
||||||
// query is still active when connection is broken
|
// query is still active when connection is broken
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect($connectionInfo, array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ; $connectionInfo", $uid, $pwd );
|
} catch (PDOException $e) {
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Could not connect.\n";
|
echo "Could not connect.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$query1 = "SELECT * FROM $tableName1";
|
$query1 = "SELECT * FROM $tableName1";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$stmt5 = $conn->query($query1);
|
||||||
$stmt5 = $conn->query( $query1 );
|
if ($stmt5) {
|
||||||
if ( $stmt5 ) echo "Statement 5 successful.\n";
|
echo "Statement 5 successful.\n";
|
||||||
|
}
|
||||||
|
|
||||||
$rowcount = $stmt5->rowCount();
|
$rowcount = $stmt5->rowCount();
|
||||||
echo $rowcount." rows in result set.\n";
|
echo $rowcount." rows in result set.\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Error executing statement 5.\n";
|
echo "Error executing statement 5.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakConnection( $conn, $conn_break );
|
breakConnection($conn, $conn_break);
|
||||||
|
|
||||||
$query2 = "SELECT * FROM $tableName2";
|
$query2 = "SELECT * FROM $tableName2";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$stmt6 = $conn->query($query2);
|
||||||
$stmt6 = $conn->query( $query2 );
|
if ($stmt6) {
|
||||||
if ( $stmt6 ) echo "Statement 6 successful.\n";
|
echo "Statement 6 successful.\n";
|
||||||
|
}
|
||||||
|
|
||||||
$rowcount = $stmt6->rowCount();
|
$rowcount = $stmt6->rowCount();
|
||||||
echo $rowcount." rows in result set.\n";
|
echo $rowcount." rows in result set.\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Error executing statement 6.\n";
|
echo "Error executing statement 6.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = null;
|
unset($conn);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Part 4
|
// Part 4
|
||||||
// Expected to trigger an error because there are two active statements with
|
// Expected to trigger an error because there are two active statements with
|
||||||
// pending results and MARS is off
|
// pending results and MARS is off
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$connectionInfo = "ConnectRetryCount = 10; ConnectRetryInterval = 10; MultipleActiveResultSets = false;";
|
$connectionInfo = "ConnectRetryCount = 10; ConnectRetryInterval = 10; MultipleActiveResultSets = false;";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect($connectionInfo, array(), PDO::ERRMODE_EXCEPTION, true);
|
||||||
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ; $connectionInfo", $uid, $pwd );
|
} catch (PDOException $e) {
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
echo "Could not connect.\n";
|
echo "Could not connect.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
BreakConnection( $conn, $conn_break );
|
breakConnection($conn, $conn_break);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$stmt7 = $conn->query("SELECT * FROM $tableName1");
|
||||||
$stmt7 = $conn->query( "SELECT * FROM $tableName1" );
|
if ($stmt7) {
|
||||||
if ( $stmt7 ) echo "Statement 7 successful.\n";
|
echo "Statement 7 successful.\n";
|
||||||
}
|
}
|
||||||
catch( PDOException $e )
|
} catch (PDOException $e) {
|
||||||
{
|
|
||||||
echo "Error executing statement 7.\n";
|
echo "Error executing statement 7.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$stmt8 = $conn->query("SELECT * FROM $tableName2");
|
||||||
$stmt8 = $conn->query( "SELECT * FROM $tableName2" );
|
if ($stmt8) {
|
||||||
if ( $stmt8 ) echo "Statement 8 successful.\n";
|
echo "Statement 8 successful.\n";
|
||||||
}
|
}
|
||||||
catch( PDOException $e )
|
} catch (PDOException $e) {
|
||||||
{
|
|
||||||
echo "Error executing statement 8.\n";
|
echo "Error executing statement 8.\n";
|
||||||
print_r( $e->getMessage() );
|
print_r($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn = null;
|
unset($conn);
|
||||||
$conn_break = null;
|
unset($conn_break);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTREGEX--
|
--EXPECTREGEX--
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test the PDO::errorCode() and PDO::errorInfo() methods.
|
Test the PDO::errorCode() and PDO::errorInfo() methods.
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once 'MsCommon.inc';
|
require_once("MsData_PDO_AllTypes.inc");
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// query with a wrong column name.
|
|
||||||
$db->query( "Select * from " . $table1 . " where IntColX = 1" );
|
|
||||||
}
|
|
||||||
|
|
||||||
catch( PDOException $e ) {
|
try {
|
||||||
|
$db = connect();
|
||||||
|
$tbname = "PDO_MainTypes";
|
||||||
|
createTableMainTypes($db, $tbname);
|
||||||
|
// query with a wrong column name.
|
||||||
|
$db->query("SELECT * FROM $tbname WHERE IntColX = 1");
|
||||||
|
|
||||||
|
dropTable($db, $tbname);
|
||||||
|
unset($conn);
|
||||||
|
} catch (PDOException $e) {
|
||||||
print($db->errorCode());
|
print($db->errorCode());
|
||||||
echo "\n";
|
echo "\n";
|
||||||
print_r($db->errorInfo());
|
print_r($db->errorInfo());
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
?>
|
|
||||||
--EXPECTREGEX--
|
--EXPECTREGEX--
|
||||||
42S22
|
42S22
|
||||||
Array
|
Array
|
||||||
|
|
|
@ -1,50 +1,59 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test the different type of data for retrieving
|
Test the different type of data for retrieving
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'MsCommon.inc';
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
require_once("MsData_PDO_AllTypes.inc");
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$db = connect();
|
$db = connect();
|
||||||
|
$tbname = "PDO_AllTypes";
|
||||||
|
createTableAllTypes($db, $tbname);
|
||||||
$query = "INSERT INTO PDO_AllTypes (";
|
|
||||||
$query .= "BigIntCol,BitCol,IntCol,";
|
$bin = fopen('php://memory', 'a');
|
||||||
$query .= "SmallIntCol,TinyIntCol,";
|
fwrite($bin, '00');
|
||||||
$query .= "DecimalCol,NumCol,MoneyCol,";
|
rewind($bin);
|
||||||
$query .= "SmallMoneyCol,FloatCol,RealCol,";
|
$inputs = array("BigIntCol" => 0,
|
||||||
$query .= "CharCol,VarcharCol,TextCol,";
|
"BitCol" => '0',
|
||||||
$query .= "NCharCol,NVarcharCol,ImageCol,";
|
"IntCol" => 1,
|
||||||
$query .= "BinaryCol,VarbinaryCol,SmallDTCol,";
|
"SmallIntCol" => 1,
|
||||||
$query .= "DateTimeCol,DTOffsetCol,";
|
"TinyIntCol" => 1,
|
||||||
$query .= "TimeCol,Guidcol,VarbinaryMaxCol,";
|
"DecimalCol" => 111,
|
||||||
$query .= "VarcharMaxCol,XmlCol,NTextCol,";
|
"NumCol" => 1,
|
||||||
$query .= "NVarCharMaxCol) VALUES (1,'0',1,1,1,111,1,";
|
"MoneyCol" => 111.1110,
|
||||||
$query .= "111.1110,111.1110,111.111,111.111,";
|
"SmallMoneyCol" => 111.1110,
|
||||||
$query .= "'STRINGCOL1','STRINGCOL1',";
|
"FloatCol" => 111.111,
|
||||||
$query .= "'1 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.',";
|
"RealCol" => 111.111,
|
||||||
$query .= "'STRINGCOL1','STRINGCOL1','00',";
|
"CharCol" => 'STRINGCOL1',
|
||||||
$query .= "CONVERT(BINARY(2),'0000000000',2),CONVERT(VARBINARY(2),CAST('00' AS VARCHAR(2)),2),'2000-11-11 11:11:00',";
|
"VarcharCol" => 'STRINGCOL1',
|
||||||
$query .= "'2000-11-11 11:11:11.110',";
|
"TextCol" => '1 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.',
|
||||||
$query .= "'2000-11-11 11:11:11.1110000 +00:00','11:11:11.1110000',";
|
"NCharCol" => 'STRINGCOL1',
|
||||||
$query .= "'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA',CONVERT(VARBINARY(MAX),CAST('00' AS VARCHAR(MAX)),2) ,";
|
"NVarcharCol" => 'STRINGCOL1',
|
||||||
$query .= "'1 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.',";
|
"ImageCol" => new BindParamOp(17, $bin, "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
$query .= "'<xml> 1 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.</xml>',";
|
"BinaryCol" => new BindParamOp(18, $bin, "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
$query .= "'1 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.',";
|
"VarbinaryCol" => new BindParamOp(19, $bin, "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
$query .= "'1 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.')";
|
"SmallDTCol" => '2000-11-11 11:11:00',
|
||||||
$numRows = $db->exec($query);
|
"DateTimeCol" => '2000-11-11 11:11:11.110',
|
||||||
|
"DTOffsetCol" => '2000-11-11 11:11:11.1110000 +00:00',
|
||||||
echo "Insert complete!";
|
"TimeCol" => '11:11:11.1110000',
|
||||||
}
|
"Guidcol" => 'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA',
|
||||||
catch(PDOException $e)
|
"VarbinaryMaxCol" => new BindParamOp(25, $bin, "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"),
|
||||||
{
|
"VarcharMaxCol" => '1 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.',
|
||||||
|
"XmlCol" => '<xml> 1 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.</xml>',
|
||||||
|
"NTextCol" => '1 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.',
|
||||||
|
"NVarCharMaxCol" => '1 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.');
|
||||||
|
$stmt = insertRow($db, $tbname, $inputs, "prepareBindParam");
|
||||||
|
|
||||||
|
dropTable($db, $tbname);
|
||||||
|
unset($stmt);
|
||||||
|
unset($conn);
|
||||||
|
echo "Insert complete!\n";
|
||||||
|
} catch (PDOException $e) {
|
||||||
var_dump($e);
|
var_dump($e);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Insert complete!
|
Insert complete!
|
||||||
|
|
|
@ -3,94 +3,84 @@ Test the PDO::prepare() method.
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
require_once("MsData_PDO_AllTypes.inc");
|
||||||
|
|
||||||
require 'MsSetup.inc';
|
try {
|
||||||
require_once 'MsCommon.inc';
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$db = connect();
|
$db = connect();
|
||||||
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
$tbname = "PDO_MainTypes";
|
||||||
|
createAndInsertTableMainTypes($db, $tbname);
|
||||||
|
|
||||||
// Test_1 : Test with no parameters
|
// Test_1 : Test with no parameters
|
||||||
echo "Test_1 : Test with no parameters :\n";
|
echo "Test_1 : Test with no parameters :\n";
|
||||||
$stmt = $db->prepare('select * from ' . $table1);
|
$stmt = $db->prepare("select * from $tbname");
|
||||||
if(!$stmt->execute())
|
if (!$stmt->execute()) {
|
||||||
{
|
|
||||||
die("Test_1 failed.");
|
die("Test_1 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
|
|
||||||
// Test_2 : Test with indexed parameters
|
// Test_2 : Test with indexed parameters
|
||||||
echo "Test_2 : Test with indexed parameters :\n";
|
echo "Test_2 : Test with indexed parameters :\n";
|
||||||
$stmt = $db->prepare('select IntCol, CharCol from ' . $table1 . ' where IntCol = ? and CharCol = ?');
|
$stmt = $db->prepare("select IntCol, CharCol from $tbname where IntCol = ? and CharCol = ?");
|
||||||
if(!$stmt->execute(array(1, 'STRINGCOL1')))
|
if (!$stmt->execute(array(1, 'STRINGCOL1'))) {
|
||||||
{
|
|
||||||
die("Test_2 failed.");
|
die("Test_2 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
|
|
||||||
// Test_3 : Test with named parameters
|
// Test_3 : Test with named parameters
|
||||||
echo "Test_3 : Test with named parameters :\n";
|
echo "Test_3 : Test with named parameters :\n";
|
||||||
$IntColVal = 2;
|
$IntColVal = 2;
|
||||||
$CharColVal = 'STRINGCOL2';
|
$CharColVal = 'STRINGCOL2';
|
||||||
$stmt = $db->prepare('select IntCol, CharCol from ' . $table1 . ' where IntCol = :IntColVal and CharCol = :CharColVal');
|
$stmt = $db->prepare("select IntCol, CharCol from $tbname where IntCol = :IntColVal and CharCol = :CharColVal");
|
||||||
if(!$stmt->execute(array(':IntColVal' => $IntColVal, ':CharColVal' => $CharColVal)))
|
if (!$stmt->execute(array(':IntColVal' => $IntColVal, ':CharColVal' => $CharColVal))) {
|
||||||
{
|
|
||||||
die("Test_3 failed.");
|
die("Test_3 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
|
|
||||||
// Test_4: Test single prepare, multiple execution with indexed parameters
|
// Test_4: Test single prepare, multiple execution with indexed parameters
|
||||||
echo "Test_4 : Test single prepare, multiple execution with indexed parameters :\n";
|
echo "Test_4 : Test single prepare, multiple execution with indexed parameters :\n";
|
||||||
$IntColVal = 1;
|
$IntColVal = 1;
|
||||||
$stmt = $db->prepare('select IntCol from ' . $table1 . ' where IntCol = ?');
|
$stmt = $db->prepare("select IntCol from $tbname where IntCol = ?");
|
||||||
$stmt->bindParam(1, $IntColVal);
|
$stmt->bindParam(1, $IntColVal);
|
||||||
if(!$stmt->execute())
|
if (!$stmt->execute()) {
|
||||||
{
|
|
||||||
die("Test_4 failed.");
|
die("Test_4 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
|
|
||||||
// Execute the stmt again
|
// Execute the stmt again
|
||||||
$IntColVal = 2;
|
$IntColVal = 2;
|
||||||
if(!$stmt->execute())
|
if (!$stmt->execute()) {
|
||||||
{
|
|
||||||
die("Test_4 failed.");
|
die("Test_4 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
|
|
||||||
// Test_5: Test single prepare, multiple execution with named parameters
|
// Test_5: Test single prepare, multiple execution with named parameters
|
||||||
echo "Test_5 : Test single prepare, multiple execution with named parameters :\n";
|
echo "Test_5 : Test single prepare, multiple execution with named parameters :\n";
|
||||||
$IntColVal = 1;
|
$IntColVal = 1;
|
||||||
$stmt = $db->prepare('select IntCol from ' . $table1 . ' where IntCol = :IntColVal');
|
$stmt = $db->prepare("select IntCol from $tbname where IntCol = :IntColVal");
|
||||||
$stmt->bindParam(':IntColVal', $IntColVal);
|
$stmt->bindParam(':IntColVal', $IntColVal);
|
||||||
if(!$stmt->execute())
|
if (!$stmt->execute()) {
|
||||||
{
|
|
||||||
die("Test_5 failed.");
|
die("Test_5 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
|
|
||||||
// Execute the stmt again
|
// Execute the stmt again
|
||||||
$IntColVal = 2;
|
$IntColVal = 2;
|
||||||
if(!$stmt->execute())
|
if (!$stmt->execute()) {
|
||||||
{
|
|
||||||
die("Test_5 failed.");
|
die("Test_5 failed.");
|
||||||
}
|
}
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
}
|
} catch (PDOException $err) {
|
||||||
catch(PDOException $err)
|
|
||||||
{
|
|
||||||
var_dump($err);
|
var_dump($err);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,81 +1,82 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
prepare with emulate prepare and binding integer
|
prepare with emulate prepare and binding integer
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require('MsSetup.inc');
|
require_once('MsCommon_mid-refactor.inc');
|
||||||
$conn = new PDO( "sqlsrv:server=$server ; Database = $databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
$tableName = "number_types";
|
try {
|
||||||
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
$query = "IF OBJECT_ID('number_types') IS NOT NULL DROP TABLE [$tableName]";
|
$tableName = "number_types";
|
||||||
$stmt = $conn->query($query);
|
if (!isColEncrypted()) {
|
||||||
|
createTable($conn, $tableName, array("c1_decimal" => "decimal", "c2_money" => "money", "c3_float" => "float"));
|
||||||
|
} else {
|
||||||
|
// money is not supported for column encryption, use decimal(19,4) instead
|
||||||
|
createTable($conn, $tableName, array("c1_decimal" => "decimal", "c2_money" => "decimal(19,4)", "c3_float" => "float"));
|
||||||
|
}
|
||||||
|
|
||||||
$query = "CREATE TABLE [$tableName] (c1_decimal decimal, c2_money money, c3_float float)";
|
insertRow($conn, $tableName, array("c1_decimal" => 411.1, "c2_money" => 131.11, "c3_float" => 611.111));
|
||||||
$stmt = $conn->query($query);
|
insertRow($conn, $tableName, array("c1_decimal" => 422.2222, "c2_money" => 132.22, "c3_float" => 622.22));
|
||||||
|
insertRow($conn, $tableName, array("c1_decimal" => 433.333, "c2_money" => 133.3333, "c3_float" => 633.33333));
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (c1_decimal, c2_money, c3_float) VALUES (411.1, 131.11, 611.111)";
|
$query = "SELECT * FROM [$tableName] WHERE c3_float = :c3";
|
||||||
$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (c1_decimal, c2_money, c3_float) VALUES (422.2222, 132.222, 622.22)";
|
// prepare without emulate prepare
|
||||||
$stmt = $conn->query($query);
|
print_r("Prepare without emulate prepare:\n");
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => false);
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$c3 = 611.111;
|
||||||
|
$stmt->bindParam(':c3', $c3);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (c1_decimal, c2_money, c3_float) VALUES (433.333, 133.3333, 633.33333 )";
|
//with emulate prepare and no bind param options
|
||||||
$stmt = $conn->query($query);
|
print_r("Prepare with emulate prepare and no bind param options:\n");
|
||||||
|
if (!isColEncrypted()) {
|
||||||
|
// emulate prepare is not supported for encrypted columns
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => true);
|
||||||
|
}
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$stmt->bindParam(':c3', $c3);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
$query = "SELECT * FROM [$tableName] WHERE c3_float = :c3";
|
//with emulate prepare and encoding SQLSRV_ENCODING_SYSTEM
|
||||||
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:\n");
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$stmt->bindParam(':c3', $c3, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
// prepare without emulate prepare
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_UTF8
|
||||||
print_r("Prepare without emulate prepare:\n");
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => false));
|
$stmt = $conn->prepare($query, $options);
|
||||||
$c3 = 611.111;
|
$stmt->bindParam(':c3', $c3, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
||||||
$stmt->bindParam(':c3', $c3);
|
$stmt->execute();
|
||||||
$stmt->execute();
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
print_r($row);
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//with emulate prepare and no bind param options
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
||||||
print_r("Prepare with emulate prepare and no bind param options:\n");
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:\n");
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
$stmt = $conn->prepare($query, $options);
|
||||||
$c3 = 611.111;
|
$stmt->bindParam(':c3', $c3, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||||
$stmt->bindParam(':c3', $c3);
|
$stmt->execute();
|
||||||
$stmt->execute();
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
print_r($row);
|
||||||
print_r($row);
|
if ($stmt->rowCount() == 0) {
|
||||||
|
print_r("No results for this query\n");
|
||||||
//with emulate prepare and encoding SQLSRV_ENCODING_SYSTEM
|
}
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:\n");
|
dropTable($conn, $tableName);
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
unset($stmt);
|
||||||
$c3 = 611.111;
|
unset($conn);
|
||||||
$stmt->bindParam(':c3', $c3, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
} catch (PDOException $e) {
|
||||||
$stmt->execute();
|
var_dump($e->errorInfo);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_UTF8
|
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$c3 = 611.111;
|
|
||||||
$stmt->bindParam(':c3', $c3, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$c3 = 611.111;
|
|
||||||
$stmt->bindParam(':c3', $c3, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_BINARY);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
if ($stmt->rowCount() == 0){
|
|
||||||
print_r("No results for this query\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
|
||||||
$conn=null;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -108,4 +109,4 @@ Array
|
||||||
[c3_float] => 611.11099999999999
|
[c3_float] => 611.11099999999999
|
||||||
)
|
)
|
||||||
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
|
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
|
||||||
No results for this query
|
No results for this query
|
||||||
|
|
|
@ -1,80 +1,81 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
prepare with emulate prepare and binding integer
|
prepare with emulate prepare and binding integer
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require('MsSetup.inc');
|
require_once('MsCommon_mid-refactor.inc');
|
||||||
$conn = new PDO( "sqlsrv:server=$server ; Database = $databaseName", $uid, $pwd);
|
try {
|
||||||
|
$conn = connect();
|
||||||
|
|
||||||
$tableName = "fruit";
|
$tableName = "fruit";
|
||||||
|
createTable($conn, $tableName, array("name" => "varchar(max)", "calories" => "int"));
|
||||||
|
|
||||||
$query = "IF OBJECT_ID('fruit') IS NOT NULL DROP TABLE [$tableName]";
|
insertRow($conn, $tableName, array("name" => "apple", "calories" => 150));
|
||||||
$stmt = $conn->query($query);
|
insertRow($conn, $tableName, array("name" => "banana", "calories" => 175));
|
||||||
|
insertRow($conn, $tableName, array("name" => "blueberry", "calories" => 1));
|
||||||
|
|
||||||
$query = "CREATE TABLE [$tableName] (name varchar(max), calories int)";
|
$query = "SELECT * FROM [$tableName] WHERE calories = :cal";
|
||||||
$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (name, calories) VALUES ('apple', 150)";
|
// prepare without emulate prepare
|
||||||
$stmt = $conn->query($query);
|
print_r("Prepare without emulate prepare:\n");
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => false);
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$cal = 1;
|
||||||
|
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (name, calories) VALUES ('banana', 175)";
|
// prepare with emulate prepare
|
||||||
$stmt = $conn->query($query);
|
print_r("Prepare with emulate prepare and no bindParam options:\n");
|
||||||
|
if (!isColEncrypted()) {
|
||||||
|
// emulate prepare is not supported for encrypted columns
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => true);
|
||||||
|
}
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (name, calories) VALUES ('blueberry', 1)";
|
if (!isColEncrypted()) {
|
||||||
$stmt = $conn->query($query);
|
// without emulate prepare, binding PARAM_INT with SQLSRV_ENCODING_SYSTEM is not allowed
|
||||||
|
// thus the following will not be tested when Column Encryption is enabled
|
||||||
|
|
||||||
$query = "SELECT * FROM [$tableName] WHERE calories = :cal";
|
$results = array();
|
||||||
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_SYSTEM
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||||
|
$stmt->execute();
|
||||||
|
$results["SYSTEM"] = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// prepare without emulate prepare
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_UTF8
|
||||||
print_r("Prepare without emulate prepare:\n");
|
$stmt = $conn->prepare($query, $options);
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => false));
|
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_UTF8);
|
||||||
$cal = 1;
|
$stmt->execute();
|
||||||
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT);
|
$results["UTF8"] = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
// prepare with emulate prepare
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
||||||
print_r("Prepare with emulate prepare and no bindParam options:\n");
|
$stmt = $conn->prepare($query, $options);
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||||
$cal = 1;
|
$stmt->execute();
|
||||||
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT);
|
$results["BINARY"] = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_SYSTEM
|
foreach ($results as $key => $value) {
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
if ($value['name'] != "blueberry" || $value['calories'] != 1) {
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
echo "Failed to fetch when binding parameter with $key encoding.\n";
|
||||||
$cal = 1;
|
}
|
||||||
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
}
|
||||||
$stmt->execute();
|
}
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_UTF8
|
dropTable($conn, $tableName);
|
||||||
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
unset($stmt);
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
unset($conn);
|
||||||
$cal = 1;
|
} catch (PDOException $e) {
|
||||||
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_UTF8);
|
var_dump($e->errorInfo);
|
||||||
$stmt->execute();
|
}
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
|
||||||
print_r("Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$cal = 1;
|
|
||||||
$stmt->bindParam(':cal', $cal, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_BINARY);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
$stmt = null;
|
|
||||||
$conn=null;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Prepare without emulate prepare:
|
Prepare without emulate prepare:
|
||||||
Array
|
Array
|
||||||
|
@ -88,21 +89,3 @@ Array
|
||||||
[name] => blueberry
|
[name] => blueberry
|
||||||
[calories] => 1
|
[calories] => 1
|
||||||
)
|
)
|
||||||
Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:
|
|
||||||
Array
|
|
||||||
(
|
|
||||||
[name] => blueberry
|
|
||||||
[calories] => 1
|
|
||||||
)
|
|
||||||
Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:
|
|
||||||
Array
|
|
||||||
(
|
|
||||||
[name] => blueberry
|
|
||||||
[calories] => 1
|
|
||||||
)
|
|
||||||
Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:
|
|
||||||
Array
|
|
||||||
(
|
|
||||||
[name] => blueberry
|
|
||||||
[calories] => 1
|
|
||||||
)
|
|
|
@ -1,81 +1,83 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
prepare with emulate prepare and binding integer
|
prepare with emulate prepare and binding integer
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require('MsSetup.inc');
|
require_once('MsCommon_mid-refactor.inc');
|
||||||
$conn = new PDO( "sqlsrv:server=$server ; Database = $databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
$tableName = "number_types";
|
try {
|
||||||
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
$query = "IF OBJECT_ID('number_types') IS NOT NULL DROP TABLE [$tableName]";
|
$tableName = "number_types";
|
||||||
$stmt = $conn->query($query);
|
if (!isColEncrypted()) {
|
||||||
|
createTable($conn, $tableName, array("c1_decimal" => "decimal", "c2_money" => "money", "c3_float" => "float"));
|
||||||
|
} else {
|
||||||
|
// money is not supported for column encryption, use decimal(19,4) instead
|
||||||
|
createTable($conn, $tableName, array("c1_decimal" => "decimal", "c2_money" => "decimal(19,4)", "c3_float" => "float"));
|
||||||
|
}
|
||||||
|
|
||||||
$query = "CREATE TABLE [$tableName] (c1_decimal decimal, c2_money money, c3_float float)";
|
insertRow($conn, $tableName, array("c1_decimal" => 411.1, "c2_money" => 131.11, "c3_float" => 611.111));
|
||||||
$stmt = $conn->query($query);
|
insertRow($conn, $tableName, array("c1_decimal" => 422.2222, "c2_money" => 132.22, "c3_float" => 622.22));
|
||||||
|
insertRow($conn, $tableName, array("c1_decimal" => 433.333, "c2_money" => 133.3333, "c3_float" => 633.33333));
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (c1_decimal, c2_money, c3_float) VALUES (411.1, 131.11, 611.111)";
|
$query = "SELECT * FROM [$tableName] WHERE c2_money = :c2";
|
||||||
$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (c1_decimal, c2_money, c3_float) VALUES (422.2222, 132.222, 622.22)";
|
// prepare without emulate prepare
|
||||||
$stmt = $conn->query($query);
|
print_r("Prepare without emulate prepare:\n");
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => false);
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$c2 = 133.3333;
|
||||||
|
$stmt->bindParam(':c2', $c2);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
$query = "INSERT INTO [$tableName] (c1_decimal, c2_money, c3_float) VALUES (433.333, 133.3333, 633.33333 )";
|
//with emulate prepare and no bind param options
|
||||||
$stmt = $conn->query($query);
|
print_r("Prepare with emulate prepare and no bind param options:\n");
|
||||||
|
if (!isColEncrypted()) {
|
||||||
|
// emulate prepare is not supported for encrypted columns
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => true);
|
||||||
|
}
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$stmt->bindParam(':c2', $c2);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
$query = "SELECT * FROM [$tableName] WHERE c2_money = :c2";
|
//with emulate prepare and encoding SQLSRV_ENCODING_SYSTEM
|
||||||
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:\n");
|
||||||
|
$stmt = $conn->prepare($query, $options);
|
||||||
|
$stmt->bindParam(':c2', $c2, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||||
|
$stmt->execute();
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
// prepare without emulate prepare
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_UTF8
|
||||||
print_r("Prepare without emulate prepare:\n");
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => false));
|
$stmt = $conn->prepare($query, $options);
|
||||||
$c2 = 133.3333;
|
$stmt->bindParam(':c2', $c2, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
||||||
$stmt->bindParam(':c2', $c2);
|
$stmt->execute();
|
||||||
$stmt->execute();
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
print_r($row);
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//with emulate prepare and no bind param options
|
//prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
||||||
print_r("Prepare with emulate prepare and no bind param options:\n");
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:\n");
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
$stmt = $conn->prepare($query, $options);
|
||||||
$c2 = 133.3333;
|
$stmt->bindParam(':c2', $c2, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||||
$stmt->bindParam(':c2', $c2);
|
$stmt->execute();
|
||||||
$stmt->execute();
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
print_r($row);
|
||||||
print_r($row);
|
if ($stmt->rowCount() == 0) {
|
||||||
|
print_r("No results for this query\n");
|
||||||
|
}
|
||||||
|
|
||||||
//with emulate prepare and encoding SQLSRV_ENCODING_SYSTEM
|
dropTable($conn, $tableName);
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_SYSTEM:\n");
|
unset($stmt);
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
unset($conn);
|
||||||
$c2 = 133.3333;
|
} catch (PDOException $e) {
|
||||||
$stmt->bindParam(':c2', $c2, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
var_dump($e->errorInfo);
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_UTF8
|
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$c2 = 133.3333;
|
|
||||||
$stmt->bindParam(':c2', $c2, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$c2 = 133.3333;
|
|
||||||
$stmt->bindParam(':c2', $c2, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_BINARY);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
if ($stmt->rowCount() == 0){
|
|
||||||
print_r("No results for this query\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
|
||||||
$conn=null;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -108,4 +110,4 @@ Array
|
||||||
[c3_float] => 633.33333000000005
|
[c3_float] => 633.33333000000005
|
||||||
)
|
)
|
||||||
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
|
Prepare with emulate prepare and SQLSRV_ENCODING_BINARY:
|
||||||
No results for this query
|
No results for this query
|
||||||
|
|
|
@ -1,89 +1,95 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
prepare with emulate prepare and binding uft8 characters
|
prepare with emulate prepare and binding uft8 characters
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require('MsSetup.inc');
|
require_once('MsCommon_mid-refactor.inc');
|
||||||
$conn = new PDO( "sqlsrv:server=$server ; Database = $databaseName", $uid, $pwd);
|
|
||||||
//$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
|
||||||
//$conn->setAttribute( PDO::SQLSRV_ATTR_QUERY_TIMEOUT, 1 );
|
|
||||||
|
|
||||||
$tableName = "users";
|
function prepareStmt($conn, $query, $prepareOptions = array(), $dataType = null, $length = null, $driverOptions = null)
|
||||||
|
{
|
||||||
$query = "IF OBJECT_ID('users') IS NOT NULL DROP TABLE [$tableName]";
|
$name = "가각";
|
||||||
$stmt = $conn->query($query);
|
if (!isColEncrypted()) {
|
||||||
|
$stmt = $conn->prepare($query, $prepareOptions);
|
||||||
$query = "CREATE TABLE [$tableName] (name nvarchar(max), status int, age int)";
|
$stmt->bindParam(':name', $name, $dataType, $length, $driverOptions);
|
||||||
$stmt = $conn->query($query);
|
} else {
|
||||||
|
$status = 1;
|
||||||
$query = "INSERT INTO [$tableName] (name, status, age) VALUES (N'Belle', 1, 34)";
|
$stmt = $conn->prepare($query, $prepareOptions);
|
||||||
$stmt = $conn->query($query);
|
$stmt->bindParam(':name', $name, $dataType, $length, $driverOptions);
|
||||||
|
$stmt->bindParam(':status', $status);
|
||||||
$query = "INSERT INTO [$tableName] (name, status, age) VALUES (N'Абрам', 1, 40)";
|
}
|
||||||
$stmt = $conn->query($query);
|
$stmt->execute();
|
||||||
|
return $stmt;
|
||||||
$query = "INSERT INTO [$tableName] (name, status, age) VALUES (N'가각', 1, 30)";
|
|
||||||
$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$name = "가각";
|
|
||||||
|
|
||||||
$query = "SELECT * FROM [$tableName] WHERE name = :name AND status = 1";
|
|
||||||
|
|
||||||
//without emulate prepare
|
|
||||||
print_r("Prepare without emulate prepare:\n");
|
|
||||||
$stmt = $conn->prepare($query);
|
|
||||||
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//with emulate prepare and no bind param options
|
|
||||||
print_r("Prepare with emulate prepare and no bindParam options:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$stmt->bindParam(':name', $name );
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
if ($stmt->rowCount() == 0){
|
|
||||||
print_r("No results for this query\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//with emulate prepare and SQLSRV_ENCODING_UTF8
|
try {
|
||||||
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
|
|
||||||
//with emulate prepare and SQLSRV_ENCODING_SYSTEM
|
$tableName = "users";
|
||||||
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
createTable($conn, $tableName, array("name" => "nvarchar(max)", "status" => "int", "age" => "int"));
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
if (!isColEncrypted()) {
|
||||||
$stmt->execute();
|
$conn->exec("INSERT INTO [$tableName] (name, status, age) VALUES (N'Belle', 1, 34)");
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
$conn->exec("INSERT INTO [$tableName] (name, status, age) VALUES (N'Абрам', 1, 40)");
|
||||||
print_r($row);
|
$conn->exec("INSERT INTO [$tableName] (name, status, age) VALUES (N'가각', 1, 30)");
|
||||||
if ($stmt->rowCount() == 0){
|
$query = "SELECT * FROM [$tableName] WHERE name = :name AND status = 1";
|
||||||
print_r("No results for this query\n");
|
} else {
|
||||||
|
insertRow($conn, $tableName, array("name" => "Belle", "status" => 1, "age" => 34));
|
||||||
|
insertRow($conn, $tableName, array("name" => "Абрам", "status" => 1, "age" => 40));
|
||||||
|
insertRow($conn, $tableName, array("name" => "가각", "status" => 1, "age" => 30));
|
||||||
|
$query = "SELECT * FROM [$tableName] WHERE name = :name AND status = :status";
|
||||||
|
}
|
||||||
|
|
||||||
|
//without emulate prepare
|
||||||
|
print_r("Prepare without emulate prepare:\n");
|
||||||
|
$stmt = prepareStmt($conn, $query, array(), PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
|
//with emulate prepare and no bind param options
|
||||||
|
print_r("Prepare with emulate prepare and no bindParam options:\n");
|
||||||
|
if (!isColEncrypted()) {
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => true);
|
||||||
|
} else {
|
||||||
|
$options = array(PDO::ATTR_EMULATE_PREPARES => false);
|
||||||
|
}
|
||||||
|
$stmt = prepareStmt($conn, $query, $options);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
if ($stmt->rowCount() == 0) {
|
||||||
|
print_r("No results for this query\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//with emulate prepare and SQLSRV_ENCODING_UTF8
|
||||||
|
print_r("Prepare with emulate prepare and SQLSRV_ENCODING_UTF8:\n");
|
||||||
|
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
|
||||||
|
//with emulate prepare and SQLSRV_ENCODING_SYSTEM
|
||||||
|
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
||||||
|
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
if ($stmt->rowCount() == 0) {
|
||||||
|
print_r("No results for this query\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
||||||
|
print_r("Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:\n");
|
||||||
|
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
print_r($row);
|
||||||
|
if ($stmt->rowCount() == 0) {
|
||||||
|
print_r("No results for this query\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
dropTable($conn, $tableName);
|
||||||
|
unset($stmt);
|
||||||
|
unset($conn);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e->errorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
|
||||||
print_r("Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:\n");
|
|
||||||
$stmt = $conn->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true));
|
|
||||||
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_BINARY);
|
|
||||||
$stmt->execute();
|
|
||||||
$row = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
||||||
print_r($row);
|
|
||||||
if ($stmt->rowCount() == 0){
|
|
||||||
print_r("No results for this query\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
//$query = "DROP TABLE [$tableName]";
|
|
||||||
//$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$stmt = null;
|
|
||||||
$conn=null;
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -106,4 +112,4 @@ Array
|
||||||
Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:
|
Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:
|
||||||
No results for this query
|
No results for this query
|
||||||
Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:
|
Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:
|
||||||
No results for this query
|
No results for this query
|
||||||
|
|
|
@ -1,33 +1,28 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test PDO::prepare by passing in invalid cursor value
|
Test PDO::prepare by passing in invalid cursor value
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once("MsSetup.inc");
|
|
||||||
|
try {
|
||||||
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$conn = new PDO( "sqlsrv:Server = $server; database = $databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
// PDO::CURSOR_FWDONLY should not be quoted
|
// PDO::CURSOR_FWDONLY should not be quoted
|
||||||
$stmt1 = $conn->prepare( "SELECT 1", array( PDO::ATTR_CURSOR => "PDO::CURSOR_FWDONLY" ));
|
$stmt1 = $conn->prepare("SELECT 1", array( PDO::ATTR_CURSOR => "PDO::CURSOR_FWDONLY" ));
|
||||||
print_r(($conn->errorInfo())[2]);
|
|
||||||
echo "\n";
|
|
||||||
|
|
||||||
// 10 is an invalid value for PDO::ATTR_CURSOR
|
|
||||||
$stmt2 = $conn->prepare( "SELECT 2", array( PDO::ATTR_CURSOR => 10 ));
|
|
||||||
print_r(($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
// 10 is an invalid value for PDO::ATTR_CURSOR
|
||||||
|
$stmt2 = $conn->prepare("SELECT 2", array( PDO::ATTR_CURSOR => 10 ));
|
||||||
|
print_r(($conn->errorInfo())[2]);
|
||||||
|
echo "\n";
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e->errorInfo);
|
||||||
}
|
}
|
||||||
catch( PDOException $e ) {
|
?>
|
||||||
var_dump( $e->errorInfo );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
An invalid cursor type was specified for either PDO::ATTR_CURSOR or PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE
|
An invalid cursor type was specified for either PDO::ATTR_CURSOR or PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE
|
||||||
An invalid cursor type was specified for either PDO::ATTR_CURSOR or PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE
|
An invalid cursor type was specified for either PDO::ATTR_CURSOR or PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE
|
||||||
|
|
|
@ -1,32 +1,28 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test PDO::prepare by passing in invalid encoding values
|
Test PDO::prepare by passing in invalid encoding values
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once("MsSetup.inc");
|
|
||||||
|
try {
|
||||||
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$conn = new PDO( "sqlsrv:Server = $server; database = $databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
// PDO::SQLSRV_ENCODING_SYSTEM should not be quoted
|
// PDO::SQLSRV_ENCODING_SYSTEM should not be quoted
|
||||||
$stmt1 = $conn->prepare( "SELECT 1", array( PDO::SQLSRV_ATTR_ENCODING => "PDO::SQLSRV_ENCODING_SYSTEM" ));
|
$stmt1 = $conn->prepare("SELECT 1", array( PDO::SQLSRV_ATTR_ENCODING => "PDO::SQLSRV_ENCODING_SYSTEM" ));
|
||||||
print_r(($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// 10 is an invalid value for PDO::SQLSRV_ATTR_ENCODING
|
// 10 is an invalid value for PDO::SQLSRV_ATTR_ENCODING
|
||||||
$stmt2 = $conn->prepare( "SELECT 2", array( PDO::SQLSRV_ATTR_ENCODING => 10 ));
|
$stmt2 = $conn->prepare("SELECT 2", array( PDO::SQLSRV_ATTR_ENCODING => 10 ));
|
||||||
print_r(($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e->errorInfo);
|
||||||
}
|
}
|
||||||
catch( PDOException $e ) {
|
?>
|
||||||
var_dump( $e->errorInfo );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
||||||
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test PDO::prepare by passing in a string key
|
Test PDO::prepare by passing in a string key
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once("MsSetup.inc");
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect();
|
||||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
|
||||||
$attr = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
|
$stmt = $conn->prepare("SELECT 1", array( "PDO::ATTR_CURSOR" => PDO::CURSOR_FWDONLY ));
|
||||||
$conn = new PDO( $dsn, $uid, $pwd, $attr);
|
|
||||||
|
|
||||||
$stmt = $conn->prepare( "SELECT 1", array( "PDO::ATTR_CURSOR" => PDO::CURSOR_FWDONLY ));
|
|
||||||
|
|
||||||
echo "Test Successful";
|
echo "Test Successful";
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e->errorInfo);
|
||||||
}
|
}
|
||||||
catch( PDOException $e ) {
|
?>
|
||||||
var_dump( $e->errorInfo );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
array(3) {
|
array(3) {
|
||||||
[0]=>
|
[0]=>
|
||||||
string(5) "IMSSP"
|
string(5) "IMSSP"
|
||||||
|
@ -30,4 +25,4 @@ array(3) {
|
||||||
int(-43)
|
int(-43)
|
||||||
[2]=>
|
[2]=>
|
||||||
string(42) "An invalid statement option was specified."
|
string(42) "An invalid statement option was specified."
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,29 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test PDO::prepare by passing in invalid scrollable type value
|
Test PDO::prepare by passing in invalid scrollable type value
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once("MsSetup.inc");
|
|
||||||
|
try {
|
||||||
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$conn = new PDO( "sqlsrv:Server = $server; database = $databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
// PDO::SQLSRV_CURSOR_BUFFERED should not be quoted
|
// 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" ));
|
$stmt1 = $conn->prepare("SELECT 1", array( PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => "PDO::SQLSRV_CURSOR_BUFFERED" ));
|
||||||
|
|
||||||
// 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 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) {
|
||||||
echo "Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE should return false.\n";
|
echo "Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE should return false.\n";
|
||||||
} else {
|
} else {
|
||||||
echo "Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE return false.\n";
|
echo "Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE return false.\n";
|
||||||
}
|
}
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e ) {
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE return false.
|
||||||
Invalid values for PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE return false.
|
|
||||||
|
|
|
@ -1,38 +1,34 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test PDO::prepare by passing in attributes
|
Test PDO::prepare by passing in attributes
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("MsSetup.inc");
|
|
||||||
|
|
||||||
try
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
{
|
|
||||||
|
try {
|
||||||
class CustomPDOStatement extends PDOStatement
|
class CustomPDOStatement extends PDOStatement
|
||||||
{
|
{
|
||||||
protected function __construct() {
|
protected function __construct()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
$conn = connect();
|
||||||
|
|
||||||
$prep_attr = array(PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_UTF8,
|
$prep_attr = array(PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_UTF8,
|
||||||
PDO::ATTR_STATEMENT_CLASS => array('CustomPDOStatement', array()),
|
PDO::ATTR_STATEMENT_CLASS => array('CustomPDOStatement', array()),
|
||||||
PDO::SQLSRV_ATTR_DIRECT_QUERY => true,
|
PDO::SQLSRV_ATTR_DIRECT_QUERY => true,
|
||||||
PDO::ATTR_EMULATE_PREPARES => false,
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true
|
PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true);
|
||||||
);
|
$stmt = $conn->prepare("SELECT 1", $prep_attr);
|
||||||
$conn = new PDO( $dsn, $uid, $pwd);
|
|
||||||
|
|
||||||
$stmt = $conn->prepare( "SELECT 1", $prep_attr );
|
|
||||||
|
|
||||||
echo "Test Successful";
|
echo "Test Successful";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch( PDOException $e ) {
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
Test Successful
|
||||||
Test Successful
|
|
||||||
|
|
|
@ -3,83 +3,80 @@ Test the PDO::query() method.
|
||||||
--ENV--
|
--ENV--
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once 'MsCommon.inc';
|
require_once("MsData_PDO_AllTypes.inc");
|
||||||
|
|
||||||
|
function queryDefault($conn, $tbname)
|
||||||
function query_default( $conn )
|
|
||||||
{
|
{
|
||||||
global $table1;
|
$stmt = $conn->query("Select * from $tbname");
|
||||||
$stmt = $conn->query( "Select * from " . $table1 );
|
|
||||||
$result = $stmt->fetch();
|
$result = $stmt->fetch();
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function query_column( $conn )
|
|
||||||
{
|
|
||||||
global $table1;
|
|
||||||
$stmt = $conn->query( "Select * from " . $table1, PDO::FETCH_COLUMN, 2 );
|
|
||||||
$result = $stmt->fetch();
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function query_class( $conn )
|
|
||||||
{
|
|
||||||
global $table1;
|
|
||||||
global $table1_class;
|
|
||||||
$stmt = $conn->query( "Select * from " . $table1, PDO::FETCH_CLASS, $table1_class );
|
|
||||||
$result = $stmt->fetch();
|
|
||||||
$result->dumpAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
function query_into( $conn )
|
|
||||||
{
|
|
||||||
global $table1;
|
|
||||||
global $table1_class;
|
|
||||||
$obj = new $table1_class;
|
|
||||||
$stmt = $conn->query( "Select * from " . $table1, PDO::FETCH_INTO, $obj );
|
|
||||||
$result = $stmt->fetch();
|
|
||||||
$result->dumpAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
function query_empty_table( $conn )
|
|
||||||
{
|
|
||||||
CreateTableEx($conn, 'emptyTable', "c1 INT, c2 INT");
|
|
||||||
$stmt = $conn->query( "Select * from emptyTable");
|
|
||||||
$result = $stmt->fetch();
|
|
||||||
var_dump($result);
|
|
||||||
DropTable($conn, 'emptyTable');
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
function queryColumn($conn, $tbname)
|
||||||
{
|
{
|
||||||
|
$stmt = $conn->query("Select * from $tbname", PDO::FETCH_COLUMN, 2);
|
||||||
|
$result = $stmt->fetch();
|
||||||
|
var_dump($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryClass($conn, $tbname)
|
||||||
|
{
|
||||||
|
global $mainTypesClass;
|
||||||
|
$stmt = $conn->query("Select * from $tbname", PDO::FETCH_CLASS, $mainTypesClass);
|
||||||
|
$result = $stmt->fetch();
|
||||||
|
$result->dumpAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryInto($conn, $tbname)
|
||||||
|
{
|
||||||
|
global $mainTypesClass;
|
||||||
|
$obj = new $mainTypesClass;
|
||||||
|
$stmt = $conn->query("Select * from $tbname", PDO::FETCH_INTO, $obj);
|
||||||
|
$result = $stmt->fetch();
|
||||||
|
$result->dumpAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryEmptyTable($conn)
|
||||||
|
{
|
||||||
|
createTable($conn, 'emptyTable', array("c1" => "int", "c2" => "int"));
|
||||||
|
$stmt = $conn->query("Select * from emptyTable");
|
||||||
|
$result = $stmt->fetch();
|
||||||
|
var_dump($result);
|
||||||
|
dropTable($conn, 'emptyTable');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$db = connect();
|
$db = connect();
|
||||||
|
$tbname = "PDO_MainTypes";
|
||||||
|
createAndInsertTableMainTypes($db, $tbname);
|
||||||
echo "TEST_1 : query with default fetch style :\n";
|
echo "TEST_1 : query with default fetch style :\n";
|
||||||
query_default($db);
|
queryDefault($db, $tbname);
|
||||||
|
|
||||||
echo "TEST_2 : query with FETCH_COLUMN :\n";
|
echo "TEST_2 : query with FETCH_COLUMN :\n";
|
||||||
query_column($db);
|
queryColumn($db, $tbname);
|
||||||
|
|
||||||
echo "TEST_3 : query with FETCH_CLASS :\n";
|
echo "TEST_3 : query with FETCH_CLASS :\n";
|
||||||
query_class($db);
|
queryClass($db, $tbname);
|
||||||
|
|
||||||
echo "TEST_4 : query with FETCH_INTO :\n";
|
echo "TEST_4 : query with FETCH_INTO :\n";
|
||||||
query_into($db);
|
queryInto($db, $tbname);
|
||||||
|
|
||||||
echo "TEST_5 : query an empty table :\n";
|
|
||||||
query_empty_table($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
catch( PDOException $e ) {
|
echo "TEST_5 : query an empty table :\n";
|
||||||
var_dump( $e );
|
queryEmptyTable($db);
|
||||||
|
|
||||||
|
dropTable($db, $tbname);
|
||||||
|
unset($db);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
TEST_1 : query with default fetch style :
|
TEST_1 : query with default fetch style :
|
||||||
array(16) {
|
array(16) {
|
||||||
|
@ -137,4 +134,4 @@ string(10) "STRINGCOL1"
|
||||||
string(7) "111.111"
|
string(7) "111.111"
|
||||||
string(431) "<xml> 1 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.</xml>"
|
string(431) "<xml> 1 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.</xml>"
|
||||||
TEST_5 : query an empty table :
|
TEST_5 : query an empty table :
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
|
@ -1,73 +1,50 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
test query time out at the connection level and statement level
|
test query time out at the connection level and statement level
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
include 'MsCommon.inc';
|
function queryTimeout($connLevel)
|
||||||
|
|
||||||
function QueryTimeout($connLevel)
|
|
||||||
{
|
{
|
||||||
require("MsSetup.inc");
|
$conn = connect('', array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
$tableName = GetTempTableName();
|
$tableName = getTableName();
|
||||||
|
createTable($conn, $tableName, array("c1_int" => "int", "c2_varchar" => "varchar(25)"));
|
||||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
|
||||||
|
insertRow($conn, $tableName, array("c1_int" => 1, "c2_varchar" => "QueryTimeout 1"));
|
||||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_varchar] varchar(25))");
|
insertRow($conn, $tableName, array("c1_int" => 2, "c2_varchar" => "QueryTimeout 2"));
|
||||||
|
|
||||||
$query = "INSERT INTO $tableName ([c1_int], [c2_varchar]) VALUES (1, 'QueryTimeout 1')";
|
|
||||||
$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$query = "INSERT INTO $tableName ([c1_int], [c2_varchar]) VALUES (2, 'QueryTimeout 2')";
|
|
||||||
$stmt = $conn->query($query);
|
|
||||||
|
|
||||||
$query = "SELECT * FROM $tableName";
|
$query = "SELECT * FROM $tableName";
|
||||||
|
|
||||||
if ($connLevel)
|
if ($connLevel) {
|
||||||
{
|
|
||||||
echo "Setting query timeout as an attribute in connection\n";
|
echo "Setting query timeout as an attribute in connection\n";
|
||||||
$conn->setAttribute(constant('PDO::SQLSRV_ATTR_QUERY_TIMEOUT'), 1);
|
$conn->setAttribute(constant('PDO::SQLSRV_ATTR_QUERY_TIMEOUT'), 1);
|
||||||
$stmt = $conn->query("WAITFOR DELAY '00:00:03'; $query");
|
$stmt = $conn->query("WAITFOR DELAY '00:00:03'; $query");
|
||||||
|
|
||||||
var_dump($conn->errorInfo());
|
var_dump($conn->errorInfo());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "Setting query timeout in the statement\n";
|
echo "Setting query timeout in the statement\n";
|
||||||
$stmt = $conn->prepare("WAITFOR DELAY '00:00:03'; $query", array(constant('PDO::SQLSRV_ATTR_QUERY_TIMEOUT') => 1));
|
$stmt = $conn->prepare("WAITFOR DELAY '00:00:03'; $query", array(constant('PDO::SQLSRV_ATTR_QUERY_TIMEOUT') => 1));
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
var_dump($stmt->errorInfo());
|
var_dump($stmt->errorInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropTable($conn, $tableName);
|
||||||
$conn = null;
|
unset($stmt);
|
||||||
|
unset($conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function RunTest()
|
echo "Starting test...\n";
|
||||||
{
|
try {
|
||||||
StartTest("pdo_query_timeout");
|
queryTimeout(true);
|
||||||
echo "\nStarting test...\n";
|
queryTimeout(false);
|
||||||
try
|
} catch (Exception $e) {
|
||||||
{
|
echo $e->getMessage();
|
||||||
QueryTimeout(true);
|
|
||||||
QueryTimeout(false);
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
echo "\nDone\n";
|
|
||||||
EndTest("pdo_query_timeout");
|
|
||||||
}
|
}
|
||||||
|
echo "Done\n";
|
||||||
RunTest();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTREGEX--
|
--EXPECTREGEX--
|
||||||
|
|
||||||
Starting test\.\.\.
|
Starting test\.\.\.
|
||||||
Setting query timeout as an attribute in connection
|
Setting query timeout as an attribute in connection
|
||||||
array\(3\) \{
|
array\(3\) \{
|
||||||
|
@ -87,6 +64,4 @@ array\(3\) \{
|
||||||
\[2\]=>
|
\[2\]=>
|
||||||
string\(63\) \"\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired\"
|
string\(63\) \"\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired\"
|
||||||
\}
|
\}
|
||||||
|
|
||||||
Done
|
Done
|
||||||
Test \"pdo_query_timeout\" completed successfully\.
|
|
||||||
|
|
|
@ -1,30 +1,26 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test the PDO::quote() method.
|
Test the PDO::quote() method.
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once 'MsCommon.inc';
|
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$conn = connect("", array(PDO::SQLSRV_ATTR_ENCODING => 3, PDO::ATTR_CASE => 2));
|
||||||
$conn = connect(array(PDO::SQLSRV_ATTR_ENCODING => 3, PDO::ATTR_CASE => 2));
|
|
||||||
|
|
||||||
$unquoted = "ABC'DE";
|
$unquoted = "ABC'DE";
|
||||||
$quoted1 = $conn->quote($unquoted);
|
$quoted1 = $conn->quote($unquoted);
|
||||||
$quoted2 = $conn->quote($quoted1);
|
$quoted2 = $conn->quote($quoted1);
|
||||||
|
|
||||||
var_dump($unquoted);
|
var_dump($unquoted);
|
||||||
var_dump($quoted1);
|
var_dump($quoted1);
|
||||||
var_dump($quoted2);
|
var_dump($quoted2);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
|
var_dump($e);
|
||||||
catch( PDOException $e ) {
|
|
||||||
var_dump( $e );
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
string(6) "ABC'DE"
|
string(6) "ABC'DE"
|
||||||
|
|
|
@ -1,33 +1,27 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test setting invalid value or key in connection attributes
|
Test setting invalid value or key in connection attributes
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
require_once("MsSetup.inc");
|
|
||||||
|
|
||||||
try{
|
try {
|
||||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
$conn = new PDO( $dsn, $uid, $pwd, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
|
||||||
|
|
||||||
// Negative value for query timeout: should raise error
|
// Negative value for query timeout: should raise error
|
||||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_QUERY_TIMEOUT, -1 );
|
@$conn->setAttribute(PDO::SQLSRV_ATTR_QUERY_TIMEOUT, -1);
|
||||||
print_r (($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// PDO::ATTR_CURSOR is a Statement Level Attribute only
|
// PDO::ATTR_CURSOR is a Statement Level Attribute only
|
||||||
@$conn->setAttribute( PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL );
|
@$conn->setAttribute(PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL);
|
||||||
print_r (($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch ( PDOException $e ){
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
?>
|
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
Invalid value -1 specified for option PDO::SQLSRV_ATTR_QUERY_TIMEOUT.
|
Invalid value -1 specified for option PDO::SQLSRV_ATTR_QUERY_TIMEOUT.
|
||||||
The given attribute is only supported on the PDOStatement object.
|
The given attribute is only supported on the PDOStatement object.
|
||||||
|
|
|
@ -1,39 +1,35 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test setting invalid encoding attributes
|
Test setting invalid encoding attributes
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("MsSetup.inc");
|
|
||||||
|
|
||||||
try{
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
$dsn = "sqlsrv:Server = $server; database = $databaseName";
|
|
||||||
|
|
||||||
$conn = new PDO( $dsn, $uid, $pwd, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
try {
|
||||||
|
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||||
|
|
||||||
// valid option: should have no error
|
// valid option: should have no error
|
||||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_DEFAULT );
|
@$conn->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_DEFAULT);
|
||||||
print_r (($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// PDO::SQLSRV_ENCODING_UTF8 should not be quoted
|
// PDO::SQLSRV_ENCODING_UTF8 should not be quoted
|
||||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, "PDO::SQLSRV_ENCODING_UTF8" );
|
@$conn->setAttribute(PDO::SQLSRV_ATTR_ENCODING, "PDO::SQLSRV_ENCODING_UTF8");
|
||||||
print_r (($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// PDO::SQLSRV_ENCODING_BINARY is not supported
|
// PDO::SQLSRV_ENCODING_BINARY is not supported
|
||||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_BINARY );
|
@$conn->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_BINARY);
|
||||||
print_r (($conn->errorInfo())[2]);
|
print_r(($conn->errorInfo())[2]);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
} catch (PDOException $e) {
|
||||||
catch ( PDOException $e ){
|
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
?>
|
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
||||||
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
||||||
|
|
|
@ -1,180 +1,161 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
test rowCount() with different querying method and test nextRowset() with different fetch
|
test rowCount() with different querying method and test nextRowset() with different fetch
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
include 'MsCommon.inc';
|
include_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
function RowCount_Query($exec)
|
function rowCountQuery($exec)
|
||||||
{
|
{
|
||||||
require("MsSetup.inc");
|
$conn = connect();
|
||||||
|
|
||||||
$tableName = GetTempTableName('testRowCount');
|
$tableName = getTableName('testRowCount');
|
||||||
|
createTable($conn, $tableName, array("c1_int" => "int", "c2_real" => "real"));
|
||||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE TABLE $tableName ([c1_int] int, [c2_real] real)");
|
|
||||||
|
|
||||||
$numRows = 5;
|
$numRows = 5;
|
||||||
for ($i = 1; $i <= $numRows; $i++)
|
for ($i = 1; $i <= $numRows; $i++) {
|
||||||
{
|
$r = $i * 1.0;
|
||||||
InsertData($conn, $tableName, $i);
|
insertRow($conn, $tableName, array("c1_int" => $i, "c2_real" => $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
FetchRowsets($conn, $tableName, $numRows);
|
fetchRowsets($conn, $tableName, $numRows);
|
||||||
|
|
||||||
for ($i = 1; $i <= $numRows; $i++)
|
for ($i = 1; $i <= $numRows; $i++) {
|
||||||
{
|
updateData($conn, $tableName, $i, $exec);
|
||||||
UpdateData($conn, $tableName, $i, $exec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteData($conn, $tableName, $exec);
|
deleteData($conn, $tableName, $exec);
|
||||||
|
|
||||||
$stmt = null;
|
dropTable($conn, $tableName);
|
||||||
$conn = null;
|
unset($stmt);
|
||||||
|
unset($conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function InsertData($conn, $tableName, $value)
|
function updateData($conn, $tableName, $value, $exec)
|
||||||
{
|
|
||||||
$query = "INSERT INTO $tableName VALUES ($value, $value * 1.0)";
|
|
||||||
$stmt = $conn->query($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
function UpdateData($conn, $tableName, $value, $exec)
|
|
||||||
{
|
{
|
||||||
$newValue = $value * 100;
|
$newValue = $value * 100;
|
||||||
$query = "UPDATE $tableName SET c1_int = $newValue WHERE (c1_int = $value)";
|
|
||||||
$rowCount = 0;
|
$rowCount = 0;
|
||||||
|
|
||||||
if ($exec)
|
|
||||||
{
|
|
||||||
$rowCount = $conn->exec($query);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$stmt = $conn->prepare($query);
|
|
||||||
$rowCount = $stmt->rowCount();
|
|
||||||
if ($rowCount > 0)
|
|
||||||
echo "Number of rows affected prior to execution should be 0!\n";
|
|
||||||
|
|
||||||
|
if (isColEncrypted()) {
|
||||||
|
// need to bind parameters for updating encrypted columns
|
||||||
|
$query = "UPDATE $tableName SET c1_int = ? WHERE (c1_int = ?)";
|
||||||
|
$stmt = $conn->prepare($query);
|
||||||
|
if ($rowCount > 0) {
|
||||||
|
echo "Number of rows affected prior to execution should be 0!\n";
|
||||||
|
}
|
||||||
|
$stmt->bindParam(1, $newValue);
|
||||||
|
$stmt->bindParam(2, $value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rowCount = $stmt->rowCount();
|
$rowCount = $stmt->rowCount();
|
||||||
|
} else {
|
||||||
|
$query = "UPDATE $tableName SET c1_int = $newValue WHERE (c1_int = $value)";
|
||||||
|
if ($exec) {
|
||||||
|
$rowCount = $conn->exec($query);
|
||||||
|
} else {
|
||||||
|
$stmt = $conn->prepare($query);
|
||||||
|
$rowCount = $stmt->rowCount();
|
||||||
|
if ($rowCount > 0) {
|
||||||
|
echo "Number of rows affected prior to execution should be 0!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->execute();
|
||||||
|
$rowCount = $stmt->rowCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if ($rowCount !== 1) {
|
||||||
if ($rowCount !== 1)
|
|
||||||
echo "Number of rows affected should be 1!\n";
|
echo "Number of rows affected should be 1!\n";
|
||||||
|
}
|
||||||
$stmt = null;
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CompareValues($actual, $expected)
|
function compareValues($actual, $expected)
|
||||||
{
|
{
|
||||||
if ($actual != $expected)
|
if ($actual != $expected) {
|
||||||
{
|
|
||||||
echo "Unexpected value $value returned! Expected $expected.\n";
|
echo "Unexpected value $value returned! Expected $expected.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function FetchRowsets($conn, $tableName, $numRows)
|
function fetchRowsets($conn, $tableName, $numRows)
|
||||||
{
|
{
|
||||||
$query = "SELECT [c1_int] FROM $tableName ORDER BY [c1_int]";
|
if (!isColEncrypted()) {
|
||||||
|
$query = "SELECT [c1_int] FROM $tableName ORDER BY [c1_int]";
|
||||||
|
} else {
|
||||||
|
// ORDER BY is not supported in encrypted columns
|
||||||
|
$query = "SELECT [c1_int] FROM $tableName";
|
||||||
|
}
|
||||||
$queries = $query . ';' . $query . ';' . $query;
|
$queries = $query . ';' . $query . ';' . $query;
|
||||||
$stmt = $conn->query($queries);
|
$stmt = $conn->query($queries);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($row = $stmt->fetch(PDO::FETCH_LAZY))
|
while ($row = $stmt->fetch(PDO::FETCH_LAZY)) {
|
||||||
{
|
|
||||||
$value = (int)$row['c1_int'];
|
$value = (int)$row['c1_int'];
|
||||||
CompareValues($value, ++$i);
|
compareValues($value, ++$i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i != $numRows)
|
if ($i != $numRows) {
|
||||||
{
|
|
||||||
echo "Number of rows fetched $i is unexpected!\n";
|
echo "Number of rows fetched $i is unexpected!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $stmt->nextRowset();
|
|
||||||
if ($result == false)
|
|
||||||
{
|
|
||||||
echo "Missing result sets!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $stmt->fetchAll(PDO::FETCH_NUM);
|
|
||||||
$i = 0;
|
|
||||||
foreach ($rows as $row)
|
|
||||||
{
|
|
||||||
foreach ($row as $key => $value)
|
|
||||||
{
|
|
||||||
$value = (int)$value;
|
|
||||||
CompareValues($value, ++$i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $stmt->nextRowset();
|
$result = $stmt->nextRowset();
|
||||||
if ($result == false)
|
if ($result == false) {
|
||||||
{
|
|
||||||
echo "Missing result sets!\n";
|
echo "Missing result sets!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rows = $stmt->fetchAll(PDO::FETCH_NUM);
|
||||||
|
$i = 0;
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
foreach ($row as $key => $value) {
|
||||||
|
$value = (int)$value;
|
||||||
|
compareValues($value, ++$i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $stmt->nextRowset();
|
||||||
|
if ($result == false) {
|
||||||
|
echo "Missing result sets!\n";
|
||||||
|
}
|
||||||
|
|
||||||
$stmt->bindColumn('c1_int', $value);
|
$stmt->bindColumn('c1_int', $value);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($row = $stmt->fetch(PDO::FETCH_BOUND))
|
while ($row = $stmt->fetch(PDO::FETCH_BOUND)) {
|
||||||
{
|
compareValues($value, ++$i);
|
||||||
CompareValues($value, ++$i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $stmt->nextRowset();
|
$result = $stmt->nextRowset();
|
||||||
if ($result != false)
|
if ($result != false) {
|
||||||
{
|
|
||||||
echo "Number of result sets exceeding expectation!\n";
|
echo "Number of result sets exceeding expectation!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function DeleteData($conn, $tableName, $exec)
|
function deleteData($conn, $tableName, $exec)
|
||||||
{
|
{
|
||||||
$query = "DELETE TOP(3) FROM $tableName";
|
$query = "DELETE TOP(3) FROM $tableName";
|
||||||
$rowCount = 0;
|
$rowCount = 0;
|
||||||
|
|
||||||
if ($exec)
|
if ($exec) {
|
||||||
{
|
|
||||||
$rowCount = $conn->exec($query);
|
$rowCount = $conn->exec($query);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$stmt = $conn->query($query);
|
$stmt = $conn->query($query);
|
||||||
$rowCount = $stmt->rowCount();
|
$rowCount = $stmt->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rowCount <= 0)
|
if ($rowCount <= 0) {
|
||||||
echo "Number of rows affected should be > 0!\n";
|
echo "Number of rows affected should be > 0!\n";
|
||||||
|
}
|
||||||
$stmt = null;
|
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function RunTest()
|
echo "Starting test...\n";
|
||||||
{
|
try {
|
||||||
StartTest("pdo_statement_rowcount_query");
|
rowCountQuery(true);
|
||||||
echo "\nStarting test...\n";
|
rowCountQuery(false);
|
||||||
try
|
} catch (Exception $e) {
|
||||||
{
|
echo $e->getMessage();
|
||||||
RowCount_Query(true);
|
|
||||||
RowCount_Query(false);
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
echo "\nDone\n";
|
|
||||||
EndTest("pdo_statement_rowcount_query");
|
|
||||||
}
|
}
|
||||||
|
echo "Done\n";
|
||||||
RunTest();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
Starting test...
|
Starting test...
|
||||||
|
|
||||||
Done
|
Done
|
||||||
Test "pdo_statement_rowcount_query" completed successfully.
|
|
||||||
|
|
|
@ -1,320 +1,303 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
call stored procedures with inputs of ten different datatypes to get outputs of various types
|
call stored procedures with inputs of ten different datatypes to get outputs of various types
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include 'MsCommon.inc';
|
include_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
function ProcFetch_BigInt($conn)
|
function procFetchBigInt($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('bigint');
|
$procName = getProcName('bigint');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 BIGINT, @p2 BIGINT, @p3 NCHAR(128) OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 BIGINT, @p2 BIGINT, @p3 NCHAR(128) OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(NCHAR(128), @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(NCHAR(128), @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '12345678';
|
$inValue1 = '12345678';
|
||||||
$inValue2 = '11111111';
|
$inValue2 = '11111111';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindValue(2, $inValue2);
|
$stmt->bindValue(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "23456789";
|
$expected = "23456789";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_Decimal($conn)
|
function procFetchDecimal($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('decimal');
|
$procName = getProcName('decimal');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 DECIMAL, @p2 DECIMAL, @p3 CHAR(128) OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 DECIMAL, @p2 DECIMAL, @p3 CHAR(128) OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(CHAR(128), @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(CHAR(128), @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '2.1';
|
$inValue1 = '2.1';
|
||||||
$inValue2 = '5.3';
|
$inValue2 = '5.3';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindValue(2, $inValue2);
|
$stmt->bindValue(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "7";
|
$expected = "7";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_Float($conn)
|
function procFetchFloat($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('float');
|
$procName = getProcName('float');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 FLOAT, @p2 FLOAT, @p3 FLOAT OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 FLOAT, @p2 FLOAT, @p3 FLOAT OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(FLOAT, @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(FLOAT, @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '2.25';
|
$inValue1 = '2.25';
|
||||||
$inValue2 = '5.5';
|
$inValue2 = '5.5';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindValue(2, $inValue2);
|
$stmt->bindValue(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "7.75";
|
$expected = "7.75";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_Int($conn)
|
function procFetchInt($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('int');
|
$procName = getProcName('int');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 INT, @p2 INT, @p3 INT OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 INT, @p2 INT, @p3 INT OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(INT, @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(INT, @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '1234';
|
$inValue1 = '1234';
|
||||||
$inValue2 = '5678';
|
$inValue2 = '5678';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindValue(2, $inValue2);
|
$stmt->bindValue(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "6912";
|
$expected = "6912";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_Money($conn)
|
function procFetchMoney($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('money');
|
$procName = getProcName('money');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 MONEY, @p2 MONEY, @p3 MONEY OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 MONEY, @p2 MONEY, @p3 MONEY OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(MONEY, @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(MONEY, @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '22.3';
|
$inValue1 = '22.3';
|
||||||
$inValue2 = '16.1';
|
$inValue2 = '16.1';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1, PDO::PARAM_STR);
|
$stmt->bindValue(1, $inValue1, PDO::PARAM_STR);
|
||||||
$stmt->bindParam(2, $inValue2, PDO::PARAM_STR);
|
$stmt->bindParam(2, $inValue2, PDO::PARAM_STR);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "38.40";
|
$expected = "38.40";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_Numeric($conn)
|
function procFetchNumeric($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('numeric');
|
$procName = getProcName('numeric');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 NUMERIC, @p2 NUMERIC, @p3 NCHAR(128) OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 NUMERIC, @p2 NUMERIC, @p3 NCHAR(128) OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(NCHAR(128), @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(NCHAR(128), @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '2.8';
|
$inValue1 = '2.8';
|
||||||
$inValue2 = '5.4';
|
$inValue2 = '5.4';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindParam(2, $inValue2);
|
$stmt->bindParam(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "8";
|
$expected = "8";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_Real($conn)
|
function procFetchReal($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('real');
|
$procName = getProcName('real');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 REAL, @p2 REAL, @p3 REAL OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 REAL, @p2 REAL, @p3 REAL OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(REAL, @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(REAL, @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '3.4';
|
$inValue1 = '3.4';
|
||||||
$inValue2 = '6.6';
|
$inValue2 = '6.6';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindParam(2, $inValue2);
|
$stmt->bindParam(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "10";
|
$expected = "10";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_SmallInt($conn)
|
function procFetchSmallInt($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('smallint');
|
$procName = getProcName('smallint');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 SMALLINT, @p2 SMALLINT, @p3 NCHAR(32) OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 SMALLINT, @p2 SMALLINT, @p3 NCHAR(32) OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(NCHAR(32), @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(NCHAR(32), @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '34';
|
$inValue1 = '34';
|
||||||
$inValue2 = '56';
|
$inValue2 = '56';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindParam(2, $inValue2);
|
$stmt->bindParam(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "90";
|
$expected = "90";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_SmallMoney($conn)
|
function procFetchSmallMoney($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('smallmoney');
|
$procName = getProcName('smallmoney');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 SMALLMONEY, @p2 SMALLMONEY, @p3 SMALLMONEY OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 SMALLMONEY, @p2 SMALLMONEY, @p3 SMALLMONEY OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(SMALLMONEY, @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(SMALLMONEY, @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '10';
|
$inValue1 = '10';
|
||||||
$inValue2 = '11.7';
|
$inValue2 = '11.7';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1, PDO::PARAM_STR);
|
$stmt->bindValue(1, $inValue1, PDO::PARAM_STR);
|
||||||
$stmt->bindParam(2, $inValue2, PDO::PARAM_STR);
|
$stmt->bindParam(2, $inValue2, PDO::PARAM_STR);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "21.70";
|
$expected = "21.70";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ProcFetch_TinyInt($conn)
|
function ProcFetch_TinyInt($conn)
|
||||||
{
|
{
|
||||||
$procName = GetTempProcName('tinyint');
|
$procName = getProcName('tinyint');
|
||||||
|
|
||||||
$stmt = $conn->exec("CREATE PROC $procName (@p1 TINYINT, @p2 TINYINT, @p3 CHAR(32) OUTPUT)
|
$stmt = $conn->exec("CREATE PROC $procName (@p1 TINYINT, @p2 TINYINT, @p3 CHAR(32) OUTPUT)
|
||||||
AS BEGIN SELECT @p3 = CONVERT(CHAR(32), @p1 + @p2) END");
|
AS BEGIN SELECT @p3 = CONVERT(CHAR(32), @p1 + @p2) END");
|
||||||
|
|
||||||
$inValue1 = '11';
|
$inValue1 = '11';
|
||||||
$inValue2 = '12';
|
$inValue2 = '12';
|
||||||
$outValue = '0';
|
$outValue = '0';
|
||||||
|
|
||||||
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
$stmt = $conn->prepare("{CALL $procName (?, ?, ?)}");
|
||||||
$stmt->bindValue(1, $inValue1);
|
$stmt->bindValue(1, $inValue1);
|
||||||
$stmt->bindParam(2, $inValue2);
|
$stmt->bindParam(2, $inValue2);
|
||||||
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
$stmt->bindParam(3, $outValue, PDO::PARAM_STR, 300);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$expected = "23";
|
$expected = "23";
|
||||||
$outValue = trim($outValue);
|
$outValue = trim($outValue);
|
||||||
if (strncasecmp($outValue, $expected, strlen($expected)))
|
if (strncasecmp($outValue, $expected, strlen($expected))) {
|
||||||
{
|
|
||||||
echo "Output value $outValue is unexpected! Expected $expected\n";
|
echo "Output value $outValue is unexpected! Expected $expected\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = null;
|
dropProc($conn, $procName);
|
||||||
|
unset($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function RunTest()
|
set_time_limit(0);
|
||||||
{
|
echo "Starting test...\n";
|
||||||
set_time_limit(0);
|
try {
|
||||||
StartTest("pdo_stored_proc_fetch_datatypes");
|
$conn = connect();
|
||||||
echo "\nStarting test...\n";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
include("MsSetup.inc");
|
|
||||||
$conn = new PDO( "sqlsrv:server=$server;database=$databaseName", $uid, $pwd);
|
|
||||||
|
|
||||||
ProcFetch_BigInt($conn);
|
procFetchBigInt($conn);
|
||||||
ProcFetch_Decimal($conn);
|
procFetchDecimal($conn);
|
||||||
ProcFetch_Float($conn);
|
procFetchFloat($conn);
|
||||||
ProcFetch_Int($conn);
|
procFetchInt($conn);
|
||||||
ProcFetch_Money($conn);
|
procFetchMoney($conn);
|
||||||
ProcFetch_Numeric($conn);
|
procFetchNumeric($conn);
|
||||||
ProcFetch_Real($conn);
|
procFetchReal($conn);
|
||||||
ProcFetch_SmallInt($conn);
|
procFetchSmallInt($conn);
|
||||||
ProcFetch_SmallMoney($conn);
|
procFetchSmallMoney($conn);
|
||||||
ProcFetch_TinyInt($conn);
|
ProcFetch_TinyInt($conn);
|
||||||
|
unset($conn);
|
||||||
$conn = null;
|
} catch (Exception $e) {
|
||||||
}
|
echo $e->getMessage();
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
echo "\nDone\n";
|
|
||||||
EndTest("pdo_stored_proc_fetch_datatypes");
|
|
||||||
}
|
}
|
||||||
|
echo "Done\n";
|
||||||
RunTest();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
||||||
Starting test...
|
Starting test...
|
||||||
|
|
||||||
Done
|
Done
|
||||||
Test "pdo_stored_proc_fetch_datatypes" completed successfully.
|
|
||||||
|
|
||||||
|
|
|
@ -1,494 +0,0 @@
|
||||||
--TEST--
|
|
||||||
Test the different type of data for retrieving
|
|
||||||
--SKIPIF--
|
|
||||||
<?php require('skipif.inc'); ?>
|
|
||||||
--FILE--
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once 'MsCommon.inc';
|
|
||||||
|
|
||||||
|
|
||||||
function testBigInt()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT BigIntCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testBit()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT BitCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testInt()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT IntCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testSmallInt()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT SmallIntCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testTinyInt()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT TinyIntCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testDecimal()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT DecimalCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testNumeric()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT NumCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testMoney()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT MoneyCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testSmallMoney()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
// Retrieve data type
|
|
||||||
$stmt = $db->query("SELECT SmallMoneyCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testFloat()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT FloatCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testReal()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT RealCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testChar()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT CharCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testVarchar()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT VarcharCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testText()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT TextCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testNText()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT NTextCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testNChar()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT NCharCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testNVarchar()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT NVarcharCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testImage()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT ImageCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testBinary()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT BinaryCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testVarbinary()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT VarbinaryCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testDateTime2()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT DateTime2Col FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testDatetimeoffset()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT DTOffsetCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testsmalldatetime()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT SmallDTCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testDateTime()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT DateTimeCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testDate()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT DateCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testNVarcharMax()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT NVarCharMaxCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testTime()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT TimeCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testUniqueidentifier()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT Guidcol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testVarbinaryMax()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT VarbinaryMaxCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testVarcharMax()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT VarcharMaxCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testXml()
|
|
||||||
{
|
|
||||||
$db = connect();
|
|
||||||
$stmt = $db->query("SELECT XmlCol FROM PDO_AllTypes");
|
|
||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//$db = connect();
|
|
||||||
//$sql = "INSERT INTO PDO_AllTypes(BigIntCol,BitCol,IntCol,) VALUES(" . GetSampleData(4) . ",1,)";
|
|
||||||
//$numRows = $db->exec($sql);
|
|
||||||
|
|
||||||
echo "Test_1 : bigint data type :\n";
|
|
||||||
testBigInt();
|
|
||||||
echo "Test_2 : bit data type :\n";
|
|
||||||
testBit();
|
|
||||||
echo "Test_3 : int data type :\n";
|
|
||||||
testInt();
|
|
||||||
echo "Test_4 : smallint data type:\n";
|
|
||||||
testSmallInt();
|
|
||||||
echo "Test_5 : tinyint data type:\n";
|
|
||||||
testTinyInt();
|
|
||||||
echo "Test_6 : decimal data type:\n";
|
|
||||||
testDecimal();
|
|
||||||
echo "Test_7 : numeric data type:\n";
|
|
||||||
testNumeric();
|
|
||||||
echo "Test_8 : money data type:\n";
|
|
||||||
testMoney();
|
|
||||||
echo "Test_9 : smallmoney data type:\n";
|
|
||||||
testSmallMoney();
|
|
||||||
echo "Test_10 : float data type:\n";
|
|
||||||
testFloat();
|
|
||||||
echo "Test_11 : real data type:\n";
|
|
||||||
testReal();
|
|
||||||
echo "Test_12 : char data type:\n";
|
|
||||||
testChar();
|
|
||||||
echo "Test_13 : varchar data type:\n";
|
|
||||||
testVarchar();
|
|
||||||
echo "Test_14 : text data type:\n";
|
|
||||||
testText();
|
|
||||||
echo "Test_15 : nchar data type:\n";
|
|
||||||
testNChar();
|
|
||||||
echo "Test_16 : nvarchar data type:\n";
|
|
||||||
testNVarchar();
|
|
||||||
echo "Test_17 : image data type:\n";
|
|
||||||
testImage();
|
|
||||||
echo "Test_18 : binary data type:\n";
|
|
||||||
testBinary();
|
|
||||||
echo "Test_19 : varbinary data type:\n";
|
|
||||||
testVarbinary();
|
|
||||||
echo "Test_20 : smalldatetime data type:\n";
|
|
||||||
testsmalldatetime();
|
|
||||||
echo "Test_21 : datetime data type:\n";
|
|
||||||
testDateTime();
|
|
||||||
echo "Test_22 : datetime2 data type:\n";
|
|
||||||
testsmalldatetime();
|
|
||||||
echo "Test_23 : datetimeoffset data type:\n";
|
|
||||||
testDatetimeoffset();
|
|
||||||
echo "Test_24 : time data type:\n";
|
|
||||||
testTime();
|
|
||||||
echo "Test_25 : Uniqueidentifier data type:\n";
|
|
||||||
testUniqueidentifier();
|
|
||||||
echo "Test_26 : VarbinaryMax data type:\n";
|
|
||||||
testVarbinaryMax();
|
|
||||||
echo "Test_27 : VarcharMax data type:\n";
|
|
||||||
testVarcharMax();
|
|
||||||
echo "Test_28 : xml data type:\n";
|
|
||||||
testXml();
|
|
||||||
echo "Test_29 : ntext data type:\n";
|
|
||||||
testNText();
|
|
||||||
echo "Test_30 : nvarcharmax data type:\n";
|
|
||||||
testNVarcharMax();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (PDOException $e)
|
|
||||||
{
|
|
||||||
var_dump($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
--EXPECT--
|
|
||||||
Test_1 : bigint data type :
|
|
||||||
array(1) {
|
|
||||||
["BigIntCol"]=>
|
|
||||||
string(1) "1"
|
|
||||||
}
|
|
||||||
Test_2 : bit data type :
|
|
||||||
array(1) {
|
|
||||||
["BitCol"]=>
|
|
||||||
string(1) "0"
|
|
||||||
}
|
|
||||||
Test_3 : int data type :
|
|
||||||
array(1) {
|
|
||||||
["IntCol"]=>
|
|
||||||
string(1) "1"
|
|
||||||
}
|
|
||||||
Test_4 : smallint data type:
|
|
||||||
array(1) {
|
|
||||||
["SmallIntCol"]=>
|
|
||||||
string(1) "1"
|
|
||||||
}
|
|
||||||
Test_5 : tinyint data type:
|
|
||||||
array(1) {
|
|
||||||
["TinyIntCol"]=>
|
|
||||||
string(1) "1"
|
|
||||||
}
|
|
||||||
Test_6 : decimal data type:
|
|
||||||
array(1) {
|
|
||||||
["DecimalCol"]=>
|
|
||||||
string(3) "111"
|
|
||||||
}
|
|
||||||
Test_7 : numeric data type:
|
|
||||||
array(1) {
|
|
||||||
["NumCol"]=>
|
|
||||||
string(1) "1"
|
|
||||||
}
|
|
||||||
Test_8 : money data type:
|
|
||||||
array(1) {
|
|
||||||
["MoneyCol"]=>
|
|
||||||
string(8) "111.1110"
|
|
||||||
}
|
|
||||||
Test_9 : smallmoney data type:
|
|
||||||
array(1) {
|
|
||||||
["SmallMoneyCol"]=>
|
|
||||||
string(8) "111.1110"
|
|
||||||
}
|
|
||||||
Test_10 : float data type:
|
|
||||||
array(1) {
|
|
||||||
["FloatCol"]=>
|
|
||||||
string(7) "111.111"
|
|
||||||
}
|
|
||||||
Test_11 : real data type:
|
|
||||||
array(1) {
|
|
||||||
["RealCol"]=>
|
|
||||||
string(7) "111.111"
|
|
||||||
}
|
|
||||||
Test_12 : char data type:
|
|
||||||
array(1) {
|
|
||||||
["CharCol"]=>
|
|
||||||
string(10) "STRINGCOL1"
|
|
||||||
}
|
|
||||||
Test_13 : varchar data type:
|
|
||||||
array(1) {
|
|
||||||
["VarcharCol"]=>
|
|
||||||
string(10) "STRINGCOL1"
|
|
||||||
}
|
|
||||||
Test_14 : text data type:
|
|
||||||
array(1) {
|
|
||||||
["TextCol"]=>
|
|
||||||
string(420) " 1 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."
|
|
||||||
}
|
|
||||||
Test_15 : nchar data type:
|
|
||||||
array(1) {
|
|
||||||
["NCharCol"]=>
|
|
||||||
string(10) "STRINGCOL1"
|
|
||||||
}
|
|
||||||
Test_16 : nvarchar data type:
|
|
||||||
array(1) {
|
|
||||||
["NVarcharCol"]=>
|
|
||||||
string(10) "STRINGCOL1"
|
|
||||||
}
|
|
||||||
Test_17 : image data type:
|
|
||||||
array(1) {
|
|
||||||
["ImageCol"]=>
|
|
||||||
string(1) " |