apply review changes

This commit is contained in:
v-kaywon 2017-10-10 11:34:59 -07:00
parent 55a02df5ba
commit d10af00511
34 changed files with 250 additions and 247 deletions

View file

@ -19,70 +19,35 @@ function isAEQualified($conn)
$msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"];
$server_ver = $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
$msodbcsql_maj = explode(".", $msodbcsql_ver)[0];
if ($msodbcsql_maj < 17 || explode('.', $server_ver)[0] < 13) {
if ($msodbcsql_maj < 13 || explode('.', $server_ver)[0] < 13) {
return false;
}
return true;
}
/*
// TO BE DELETED
function connect($options=array())
{
try
{
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
// which does not support switching databases
require 'MsSetup.inc';
$conn = new PDO( "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;" , $uid, $pwd, $options);
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
create_and_insert_table1($conn);
create_and_insert_table2($conn);
return $conn;
}
catch( PDOException $e )
{
var_dump( $e );
exit;
}
catch(Exception $e)
{
var_dump( $e );
exit;
}
}
*/
/**
* Connect to the database specified in MsSetup.inc; Column Encryption keywords automatically added when $keystore is not none
* @param string $keywords : string to append to the dsn string in PDO::_construct
* @param array $options : attributes to pass to PDO::_construct
* @param string $errmode : specifies how the driver reports failures: one of exception, warning, or silent; default is exception
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
* for testing fetching encrypted data when connection column encryption is off
* @return PDO connection object
*/
function connect($keywords='', $options=array(), $disableCE = false)
function connect($keywords = '', $options=array(), $errmode = "exception", $disableCE = false)
{
try {
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
// which does not support switching databases
require 'MsSetup.inc';
$dsn = "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;";
if ($keystore != "none" && !$disableCE) {
$dsn .= "ColumnEncryption=Enabled;";
}
if ($keystore == "ksp" && !$disableCE) {
require('AE_Ksp.inc');
$ksp_path = getKSPPath();
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
}
if ($keywords) {
$dsn .= $keywords;
}
require("MsSetup.inc");
$dsn = getDSN($server, $databaseName, $keywords, $disableCE);
$conn = new PDO($dsn, $uid, $pwd, $options);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (!strcasecmp($errmode, "exception") || !strcasecmp($errmode, "warning") || !strcasecmp($errmode, "silent")) {
$conn->setAttribute(PDO::ATTR_ERRMODE, constant("PDO::ERRMODE_" . strtoupper($errmode)));
} else {
printf("connect: The errmode provided must be one of exception, warning, or silent.\n");
}
return $conn;
} catch (PDOException $e) {
var_dump($e->errorInfo);
@ -94,41 +59,37 @@ function connect($keywords='', $options=array(), $disableCE = false)
/**
* Connect to the database specified in MsSetup.inc; Column Encryption keywords automatically added when $keystore is not none
* @param string $keywords : string to append to the dsn string in PDO::_construct
* @param array $options : attributes to pass to PDO::_construct
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
* for testing fetching encrypted data when connection column encryption is off
* @return PDO connection object
* @param string $sqlsrvserver : server name
* @param string $database : database name
* @param string $keywords : string to append to the dsn string in PDO::_construct
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
* @return string dsn string used for PDO constructor
*/
function ae_connect($keywords='', $options=array(), $disableCE = false)
function getDSN($sqlsrvserver, $database, $keywords = '', $disableCE = false)
{
try {
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
// which does not support switching databases
require 'MsSetup.inc';
$dsn = "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;";
if ($keystore != "none" && !$disableCE) {
$dsn .= "ColumnEncryption=Enabled;";
}
if ($keystore == "ksp" && !$disableCE) {
require('AE_Ksp.inc');
$ksp_path = getKSPPath();
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
}
if ($keywords) {
$dsn .= $keywords;
}
$conn = new PDO($dsn, $uid, $pwd, $options);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conn;
} catch (PDOException $e) {
var_dump($e);
exit;
} catch (Exception $e) {
var_dump($e);
require("MsSetup.inc");
$dsn = "";
if ($sqlsrvserver) {
$dsn .= "sqlsrv:Server=$sqlsrvserver;";
} else {
printf("getDSN: the sqlsrvserver provided must not be null.\n");
exit;
}
if ($database) {
$dsn .= "database=$database;";
}
if ($keystore != "none" && !$disableCE) {
$dsn .= "ColumnEncryption=Enabled;";
}
if ($keystore == "ksp" && !$disableCE) {
require('AE_Ksp.inc');
$ksp_path = getKSPPath();
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
}
if ($keywords) {
$dsn .= $keywords;
}
return $dsn;
}
@ -164,8 +125,8 @@ function getCekName()
*/
class ColumnMeta
{
public $colName; //column name
public $dataType; //a string that includes the size of the type if necessary (e.g., decimal(10,5))
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) )
@ -183,9 +144,22 @@ class ColumnMeta
/**
* @return string column definition for creating a table
*/
public function getColDefOps()
public function getColDef()
{
return getColDef($this->colName, $this->dataType, $this->options, $this->encType);
//return getColDef($this->colName, $this->dataType, $this->options, $this->encType);
$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
if (isColEncrypted() && stripos($this->options, "identity") === false) {
$cekName = getCekName();
if (stripos($this->dataType, "char") !== false) {
$append .= "COLLATE Latin1_General_BIN2 ";
}
$append .= sprintf("ENCRYPTED WITH (ENCRYPTION_TYPE = %s, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = $cekName) ", $this->encType);
}
$append .= $this->options;
$colDef = "[" . $this->colName . "] " . $this->dataType . $append;
return $colDef;
}
}
@ -197,6 +171,7 @@ class ColumnMeta
* @param string $encType : randomized or deterministic; default is deterministic
* @return string column definition for creating a table
*/
/*
function getColDef($colName, $dataType, $options = null, $encType = "deterministic")
{
$append = " ";
@ -213,7 +188,7 @@ function getColDef($colName, $dataType, $options = null, $encType = "determinist
$colDef = "[" . $colName . "] " . $dataType . $append;
return $colDef;
}
*/
/**
* @return string default column name when a name is not provided in the ColumnMeta class
@ -241,16 +216,14 @@ function createTable($conn, $tbname, $columnMetaArr, $disableCE = false)
try {
dropTable($conn, $tbname);
$colDef = "";
/*
foreach ($columnMetaArr as $meta) {
$colDef = $colDef . $meta->getColDefOps() . ", ";
}
*/
foreach ($columnMetaArr as $key => $value) {
if (!is_object($value)) {
$colDef = $colDef . getColDef($key, $value) . ", ";
$cm = new ColumnMeta($value, $key);
$colDef = $colDef . $cm->getColDef() . ", ";
//$colDef = $colDef . getColDef($key, $value) . ", ";
} elseif (get_class($value) == "ColumnMeta") {
$colDef = $colDef . $value->getColDefOps() . ", ";
$colDef = $colDef . $value->getColDef() . ", ";
//$colDef = $colDef . $value->getColDefOps() . ", ";
}
}
$colDef = rtrim($colDef, ", ");
@ -281,9 +254,28 @@ class BindParamOp
{
$this->parameter = $parameter;
$this->variable = $variable;
$this->pdoType = $pdoType;
$this->length = $length;
$this->options = $options;
$pdoParams = array("PDO::PARAM_BOOL", "PDO::PARAM_NULL", "PDO::PARAM_INT", "PDO::PARAM_STR", "PDO::PARAM_LOB");
if (in_array($pdoType, $pdoParams)) {
$this->pdoType = $pdoType;
} 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");
exit;
}
if ($length >= 0) {
$this->length = $length;
} else {
printf("BindParamOp construct: The length provided must be great or equal to 0.\n");
exit;
}
$encodingAttrs = array("PDO::SQLSRV_ENCODING_BINARY", "PDO::SQLSRV_ENCODING_SYSTEM", "PDO::SQLSRV_ENCODING_UTF8", "PDO::SQLSRV_ENCODING_DEFAULT");
if (in_array($options, $encodingAttrs)) {
$this->options = $options;
} 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");
}
}
/**
* @param object $stmt : PDO Statement object
@ -354,6 +346,9 @@ function insertRow($conn, $tbname, $inputs, $api = null, &$r = null)
$stmt->bindParam($i, $inputs[$key]);
} elseif (get_class($value) == "BindParamOp") {
$value->bindWithOp($stmt);
} else {
printf("insertRow: The inputs provided must be a literal value or a BindParamOp object.\n");
exit;
}
$i++;
}
@ -407,12 +402,12 @@ function getInsertSqlComplete($tbname, $inputs)
*/
function getInsertSqlPlaceholders($tbname, $inputs)
{
$colStr = "INSERT INTO $tbname (";
$valStr = "VALUES (";
if (empty($inputs)) {
echo "getInsertSqlPlaceholders: inputs for inserting a row cannot be empty.\n";
return "";
}
$colStr = "INSERT INTO $tbname (";
$valStr = "VALUES (";
foreach ($inputs as $key => $value) {
$colStr .= $key . ", ";
}

View file

@ -28,12 +28,14 @@ try {
// Fetch, get data and move the cursor to the next result set
if (!isColEncrypted()) {
$sql = "SELECT * from $tableName WHERE c1 = '204' OR c1 = '210';
$sql = "SELECT * from $tableName WHERE c1 = '204' OR c1 = '210';
SELECT Top 3 * FROM $tableName ORDER BY c1 DESC";
$stmt = $conn->query($sql);
$expected = array(array(219, sha1(219)), array(218, sha1(218)), array(217, sha1(217)));
} else {
// ORDER BY does not work for encrypted columns
// ORDER BY does not work for encrypted columns. In
//https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine,
//the Feature Details section states that operators such as greater/less than does not work for encrypted columns, and ORDER BY is based on that
$sql = "SELECT * FROM $tableName WHERE c1 = ? OR c1 = ?;
SELECT Top 3 * FROM $tableName";
$stmt = $conn->prepare($sql);
@ -44,15 +46,17 @@ try {
$data2 = $stmt->fetchAll(PDO::FETCH_NUM);
// Array: FETCH_ASSOC
foreach ($data1 as $a)
echo $a['c1'] . "|" . $a['c2'] . "\n";
foreach ($data1 as $a) {
echo $a['c1'] . "|" . $a['c2'] . "\n";
}
// Array: FETCH_NUM
if (!isColEncrypted()) {
$i = 0;
foreach ($data2 as $a) {
if ($expected[$i][0] != $a[0] || $expected[$i][1] != $a[1])
if ($expected[$i][0] != $a[0] || $expected[$i][1] != $a[1]) {
echo "Values in row $i does not match the expected output.\n";
}
$i++;
}
} else {
@ -60,18 +64,20 @@ try {
foreach ($data2 as $a) {
$match = false;
foreach ($inputs as $input) {
if ($a[0] == $input[0] && $a[1] == $input[1])
if ($a[0] == $input[0] && $a[1] == $input[1]) {
$match = true;
}
}
if (!$match)
if (!$match) {
echo "Value fetched for $a[0] is incorrect.\n";
}
}
}
}
// Close connection
dropTable($conn, $tableName);
//dropTable($conn, $tableName);
unset($stmt);
unset($con );
unset($con);
print "Done";
} catch (PDOException $e) {

View file

@ -4,11 +4,11 @@ Moves the cursor to the next result set with pooling enabled
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
require_once( "MsCommon_mid-refactor.inc" );
require_once("MsCommon_mid-refactor.inc");
try {
// Create a pool
$conn0 = connect( "ConnectionPooling=1" );
$conn0 = connect("ConnectionPooling=1");
$conn0->query("SELECT 1");
unset($conn0);
@ -25,7 +25,7 @@ try {
for ($t=200; $t<220; $t++) {
$stmt = $conn->prepare($sql);
$stmt->bindParam(1, $t);
$ts = substr(sha1($t),0,5);
$ts = substr(sha1($t), 0, 5);
$stmt->bindParam(2, $ts);
$stmt->execute();
array_push($inputs, array($t, $ts));
@ -33,12 +33,14 @@ try {
// Fetch, get data and move the cursor to the next result set
if (!isColEncrypted()) {
$sql = "SELECT * from $tableName WHERE c1 = '204' OR c1 = '210';
$sql = "SELECT * from $tableName WHERE c1 = '204' OR c1 = '210';
SELECT Top 3 * FROM $tableName ORDER BY c1 DESC";
$stmt = $conn->query($sql);
$expected = array(array(219, substr(sha1(219),0,5)), array(218, substr(sha1(218),0,5)), array(217, substr(sha1(217),0,5)));
$expected = array(array(219, substr(sha1(219), 0, 5)), array(218, substr(sha1(218), 0, 5)), array(217, substr(sha1(217), 0, 5)));
} else {
// ORDER BY does not work for encrypted columns
// ORDER BY does not work for encrypted columns. In
//https://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine,
//the Feature Details section states that operators such as greater/less than does not work for encrypted columns, and ORDER BY is based on that
$sql = "SELECT * FROM $tableName WHERE c1 = ? OR c1 = ?;
SELECT Top 3 * FROM $tableName";
$stmt = $conn->prepare($sql);
@ -49,15 +51,17 @@ try {
$data2 = $stmt->fetchAll(PDO::FETCH_NUM);
// Array: FETCH_ASSOC
foreach ($data1 as $a)
echo $a['c1']."|".$a['c2']."\n";
foreach ($data1 as $a) {
echo $a['c1']."|".$a['c2']."\n";
}
// Array: FETCH_NUM
if (!isColEncrypted()) {
$i = 0;
foreach ($data2 as $a) {
if ($expected[$i][0] != $a[0] || $expected[$i][1] != $a[1])
if ($expected[$i][0] != $a[0] || $expected[$i][1] != $a[1]) {
echo "Values in row $i does not match the expected output.\n";
}
$i++;
}
} else {
@ -65,11 +69,13 @@ try {
foreach ($data2 as $a) {
$match = false;
foreach ($inputs as $input) {
if ($a[0] == $input[0] && $a[1] == $input[1])
if ($a[0] == $input[0] && $a[1] == $input[1]) {
$match = true;
}
}
if (!$match)
if (!$match) {
echo "Value fetched for $a[0] is incorrect.\n";
}
}
}

View file

@ -8,7 +8,6 @@ require_once("MsCommon_mid-refactor.inc");
// Connect
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Create a temporary table
$tableName = '#testXMLBindValue';
@ -44,8 +43,8 @@ try {
// Get data
$row = selectAll($conn, $tableName, "PDO::FETCH_ASSOC");
var_dump($row);
var_dump($row);
// Close connection
unset($stmt);
unset($conn);

View file

@ -20,8 +20,10 @@ try {
$result;
$stmt = insertRow($conn, $tableName, array("c1" => new BindParamOp(1, $input, "PDO::PARAM_STR", 0, "PDO::SQLSRV_ENCODING_BINARY")), "prepareBindParam", $result);
if (!$result)
if (!$result) {
echo "Failed to insert!\n";
exit;
}
$stmt = $conn->query("SELECT * FROM $tableName");
$utf8 = $stmt->fetchColumn();

View file

@ -8,11 +8,13 @@ require_once("MsCommon_mid-refactor.inc");
try {
// Connect
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
// set errmode to silent to compare sqlstates in the test
$conn = connect("", array(), "silent");
// Create table
$tableName = 'pdo_040test';
// common function insertRow() is not used here since the test deliberately executes an invalid insertion statement
// thus it's not necessary to create an encrypted column for testing column encryption
$sql = "CREATE TABLE $tableName (code INT)";
$stmt = $conn->exec($sql);
@ -29,12 +31,14 @@ try {
$success = true;
if (!isColEncrypted()) {
// 21S01 is the expected ODBC Column name or number of supplied values does not match table definition error
if ($error[0] != "21S01")
if ($error[0] != "21S01") {
$success = false;
}
} else {
// 07009 is the expected ODBC Invalid Descriptor Index error
if ($error[0] != "07009")
if ($error[0] != "07009") {
$success = false;
}
}
// Close connection
@ -42,10 +46,11 @@ try {
unset($stmt);
unset($conn);
if ($success)
if ($success) {
print "Done";
else
} else {
var_dump($error);
}
} catch (PDOException $e) {
var_dump($e->errorInfo);
}

View file

@ -5,23 +5,28 @@ Exception is thrown if the unsupported attribute ATTR_PERSISTENT is put into the
--FILE--
<?php
require_once("MsSetup.inc");
// TODO: With and without column encryption in the connection string result in different behaviors
// without Column Encryption, no error is raised if PREFETCH is set before ERRMODE
// with Column Encyrption, error is raised even when PREFETCH is set before ERRMODE
// require investigation for the difference in behaviors
try {
echo "Testing a connection with ATTR_PERSISTENT...\n";
// setting PDO::ATTR_PERSISTENT in PDO constructor returns an exception
$dsn = "sqlsrv:Server = $server;database = $databaseName;";
if ($keystore != "none")
if ($keystore != "none") {
$dsn .= "ColumnEncryption=Enabled;";
if ($keystore == "ksp") {
}
if ($keystore == "ksp") {
require_once('AE_Ksp.inc');
$ksp_path = getKSPPath();
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
}
$attr = array(PDO::ATTR_PERSISTENT => true);
$conn = new PDO($dsn, $uid, $pwd, $attr);
//free the connection
$attr = array(PDO::ATTR_PERSISTENT => true);
$conn = new PDO($dsn, $uid, $pwd, $attr);
//free the connection
unset($conn);
} catch(PDOException $e) {
} catch (PDOException $e) {
echo "Exception from unsupported attribute (ATTR_PERSISTENT) is caught\n";
}
try {
@ -31,19 +36,19 @@ try {
$conn = connect();
createTable($conn, $tableName1, array("c1" => "int", "c2" => "varchar(10)"));
insertRow($conn, $tableName1, array("c1" => 1, "c2" => "column2"), "exec");
$result = selectRow($conn, $tableName1, "PDO::FETCH_ASSOC");
if ($result['c1'] == 1 && $result['c2'] == 'column2') {
echo "Test successfully completed";
}
//free the statement and connection
//free the statement and connection
dropTable($conn, $tableName);
unset($stmt);
unset($conn);
} catch(PDOException $e) {
var_dump( $e);
} catch (PDOException $e) {
var_dump($e);
}
?>
?>
--EXPECT--
Testing a connection with ATTR_PERSISTENT...
Exception from unsupported attribute (ATTR_PERSISTENT) is caught

View file

@ -8,41 +8,43 @@ require_once("MsCommon_mid-refactor.inc");
try {
$pdo_options = [];
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$pdo_options[PDO::SQLSRV_ATTR_ENCODING] = PDO::SQLSRV_ENCODING_UTF8;
$connection = connect('', $pdo_options);
// Always Encrypted does not support using DIRECT_QUERY for binding parameters
// see https://github.com/Microsoft/msphpsql/wiki/Features#aebindparam
$pdo_options = [];
if (!isColEncrypted())
$pdo_options[PDO::SQLSRV_ATTR_DIRECT_QUERY] = TRUE;
if (!isColEncrypted()) {
$pdo_options[PDO::SQLSRV_ATTR_DIRECT_QUERY] = true;
}
$pdo_options[PDO::ATTR_CURSOR] = PDO::CURSOR_SCROLL;
$pdo_options[PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE] = PDO::SQLSRV_CURSOR_BUFFERED;
$pdo_options[PDO::SQLSRV_ATTR_ENCODING] = PDO::SQLSRV_ENCODING_UTF8;
// Create table
$tbname = "TEST";
createTable($connection, $tbname, array( new ColumnMeta( "int", "id", "IDENTITY(1,1) NOT NULL" ), "name" => "nvarchar(max)"));
createTable($connection, $tbname, array( new ColumnMeta("int", "id", "IDENTITY(1,1) NOT NULL"), "name" => "nvarchar(max)"));
$prefix = '가각';
$name = '가각ácasa';
$name2 = '가각sample2';
$pdo_options[PDO::ATTR_EMULATE_PREPARES] = FALSE;
$pdo_options[PDO::ATTR_EMULATE_PREPARES] = false;
$st = $connection->prepare("INSERT INTO $tbname (name) VALUES (:p0)", $pdo_options);
$st->execute(['p0' => $name]);
// Always Encrypted does not support emulate prepare
if (!isColEncrypted())
$pdo_options[PDO::ATTR_EMULATE_PREPARES] = TRUE;
if (!isColEncrypted()) {
$pdo_options[PDO::ATTR_EMULATE_PREPARES] = true;
}
$st = $connection->prepare("INSERT INTO $tbname (name) VALUES (:p0)", $pdo_options);
$st->execute(['p0' => $name2]);
if (!isColEncrypted()) {
$statement1 = $connection->prepare("SELECT * FROM $tbname WHERE NAME LIKE :p0", $pdo_options);
$statement1->execute(['p0' => "$prefix%"]);
$pdo_options[PDO::ATTR_EMULATE_PREPARES] = FALSE;
$pdo_options[PDO::ATTR_EMULATE_PREPARES] = false;
$statement2 = $connection->prepare("SELECT * FROM $tbname WHERE NAME LIKE :p0", $pdo_options);
$statement2->execute(['p0' => "$prefix%"]);
} else {
@ -69,4 +71,4 @@ try {
FOUND: 가각ácasa
FOUND: 가각sample2
FOUND: 가각ácasa
FOUND: 가각sample2
FOUND: 가각sample2

View file

@ -73,7 +73,7 @@ try {
$cd_arr = array();
foreach ($cm_arr as $cm) {
array_push( $cd_arr, $cm->getColDefOps());
array_push( $cd_arr, $cm->getColDef());
}
$tablescript = "CREATE TABLE [dbo].[$tbname](

View file

@ -14,7 +14,6 @@ function getNextSeq($conn, $sequenceName)
}
try {
$database = "tempdb";
$conn = connect();
// sequence is only supported in SQL server 2012 and up (or version 11 and up)

View file

@ -38,11 +38,11 @@ try {
}
//test direct exec
$stmt = $conn->exec($sql);
$numrow = $conn->exec($sql);
$err = $conn->errorCode();
if ($stmt == 0 && $err == "00000") {
if ($numrow == 0 && $err == "00000") {
echo "direct exec OK\n";
} elseif ($stmt != 0) {
} elseif ($numrow != 0) {
echo "unexpected row returned at direct exec\n";
}
if ($err != "00000") {

View file

@ -3,8 +3,8 @@ This test verifies that GitHub issue #378 is fixed in pdo_sqlsrv.
--DESCRIPTION--
GitHub issue #378 - output parameters appends garbage info when variable is initialized with different data type
steps to reproduce the issue:
1- create a store procedure with print and output parameter
2- initialize output parameters to a different data type other than the type declared in sp.
1 - create a store procedure with print and output parameter
2 - initialize output parameters to a different data type other than the type declared in sp.
3 - call sp.
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
@ -23,7 +23,7 @@ try {
createSP($conn, $procName);
executeSP($conn, $procName);
executeSP($conn, $procName);
DropProc($conn, $procName);
dropProc($conn, $procName);
echo "Done\n";
unset($conn);
} catch (PDOException $e) {

View file

@ -8,8 +8,7 @@ testing the quote method with different inputs and then test with a empty query
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$conn = connect("", array(), "silent");
$output1 = $conn->quote("1'2'3'4'5'6'7'8", PDO::PARAM_INT);
var_dump($output1);

View file

@ -19,16 +19,14 @@ function testException()
function testWarning()
{
$db = connect();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db = connect("", array(), "warning");
$sql = "SELECT * FROM temp_table";
$q = $db->query($sql);
}
function testSilent()
{
$db = connect();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$db = connect("", array(), "silent");
$sql = "SELECT * FROM temp_table";
$q = $db->query($sql);
}

View file

@ -7,8 +7,9 @@ Test errorInfo when prepare with and without emulate prepare
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
// connection with and without column encryption returns different warning since column encryption cannot use emulate prepare
// turn ERRMODE to silent to compare the errorCode in the test
$conn = connect("", array(), "silent");
//drop, create and insert
$tbname = "test_table";
@ -84,4 +85,4 @@ Warning: PDOStatement::(bindParam|execute)\(\): SQLSTATE\[HY093\]: Invalid param
\*\*\*\*testing without emulate prepare\*\*\*\*
Warning: PDOStatement::bindParam\(\): SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+
Warning: PDOStatement::bindParam\(\): SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+

View file

@ -6,8 +6,8 @@ direct execution of an invalid query
<?php
require_once("MsCommon_mid-refactor.inc");
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
// set ERRMODE to silent to return in errorCode in the test
$conn = connect("", array(), "silent");
$tbname = "table1";
dropTable($conn, $tbname);

View file

@ -11,7 +11,7 @@ try {
$sample = 'asdgasdgasdgsadg';
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "varbinary(max)"));
createTable($conn, $tbname, array("c1" => "varbinary(max)"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);

View file

@ -11,7 +11,7 @@ try {
$sample = "eight";
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "varchar(10)"));
createTable($conn, $tbname, array("c1" => "varchar(10)"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);

View file

@ -11,7 +11,7 @@ try {
$sample = '2012-06-18 10:34:09';
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "datetime"));
createTable($conn, $tbname, array("c1" => "datetime"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);

View file

@ -11,7 +11,7 @@ try {
$sample = 1234567890.1234;
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "decimal(16,6)"));
createTable($conn, $tbname, array("c1" => "decimal(16,6)"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);
@ -21,8 +21,8 @@ try {
$query = "SELECT TOP 1 * FROM $tbname";
//prepare with no buffered cursor
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
$stmt->execute();
$value = $stmt->fetchColumn();
var_dump($value);

View file

@ -11,20 +11,20 @@ try {
$sample = 1234567890.1234;
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "decimal(18,8)"));
createTable($conn, $tbname, array("c1" => "decimal(18,8)"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);
$stmt->bindValue(':p0', $sample, PDO::PARAM_INT);
$stmt->execute();
$query = "SELECT exist FROM $tbname";
$query = "SELECT c1 FROM $tbname";
//prepare with no buffered cursor
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -32,7 +32,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -40,7 +40,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -48,7 +48,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, false);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -57,7 +57,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -65,7 +65,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -73,7 +73,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);
@ -81,7 +81,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, false);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $decimal_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $decimal_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($decimal_col);

View file

@ -15,7 +15,7 @@ try {
$sample = 1234567890.1234;
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "float(53)"));
createTable($conn, $tbname, array("c1" => "float(53)"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);
@ -25,8 +25,8 @@ try {
$query = "SELECT TOP 1 * FROM $tbname";
//prepare with no buffered cursor
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
$stmt->execute();
$value = $stmt->fetchColumn();
var_dump($value);

View file

@ -25,8 +25,8 @@ try {
$query = "SELECT exist FROM $tbname";
//prepare with no buffered cursor
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $float_col, PDO::PARAM_LOB);
$value = $stmt->fetch();

View file

@ -11,7 +11,7 @@ try {
$sample = 1234567890;
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "int"));
createTable($conn, $tbname, array("c1" => "int"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);

View file

@ -11,20 +11,20 @@ try {
$sample = 1234567890;
$tbname = "TESTTABLE";
createTable($conn, $tbname, array("exist" => "int"));
createTable($conn, $tbname, array("c1" => "int"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);
$stmt->bindValue(':p0', $sample, PDO::PARAM_INT);
$stmt->execute();
$query = "SELECT exist FROM $tbname";
$query = "SELECT c1 FROM $tbname";
//prepare with no buffered cursor
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -32,7 +32,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -40,7 +40,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -48,7 +48,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, false);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -57,7 +57,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -65,7 +65,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -73,7 +73,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);
@ -81,7 +81,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, false);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $int_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $int_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($int_col);

View file

@ -12,10 +12,10 @@ try {
$tbname = "TESTTABLE";
if (!isColEncrypted()) {
createTable($conn, $tbname, array("exist" => "money"));
createTable($conn, $tbname, array("c1" => "money"));
} else {
// inserting money types is not supported for Always Encrypted; use decimal(19,4) instead
createTable($conn, $tbname, array("exist" => "decimal(19,4)"));
createTable($conn, $tbname, array("c1" => "decimal(19,4)"));
}
$query = "INSERT INTO $tbname VALUES(:p0)";

View file

@ -12,10 +12,10 @@ try {
$tbname = "TESTTABLE";
if (!isColEncrypted()) {
createTable($conn, $tbname, array("exist" => "money"));
createTable($conn, $tbname, array("c1" => "money"));
} else {
// inserting money types is not supported for Always Encrypted; use decimal(19,4) instead
createTable($conn, $tbname, array("exist" => "decimal(19,4)"));
createTable($conn, $tbname, array("c1" => "decimal(19,4)"));
}
$query = "INSERT INTO $tbname VALUES(:p0)";
@ -23,13 +23,13 @@ try {
$stmt->bindValue(':p0', $sample, PDO::PARAM_INT);
$stmt->execute();
$query = "SELECT exist FROM $tbname";
$query = "SELECT c1 FROM $tbname";
//prepare with no buffered cursor
print "no buffered cursor, stringify off, fetch_numeric off\n"; //stringify and fetch_numeric is off by default
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -37,7 +37,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -45,7 +45,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -53,7 +53,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, false);
$stmt = $conn->prepare($query);
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -62,7 +62,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -70,7 +70,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -78,7 +78,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);
@ -86,7 +86,7 @@ $stmt = $conn->prepare($query);
$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, false);
$stmt = $conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
$stmt->execute();
$stmt->bindColumn('exist', $money_col, PDO::PARAM_INT);
$stmt->bindColumn('c1', $money_col, PDO::PARAM_INT);
$value = $stmt->fetch(PDO::FETCH_BOUND);
var_dump($money_col);

View file

@ -11,7 +11,7 @@ try {
$sample = "가각";
$tbname = "TERSTTABLE";
createTable($conn, $tbname, array("exist" => "nvarchar(10)"));
createTable($conn, $tbname, array("c1" => "nvarchar(10)"));
$query = "INSERT INTO $tbname VALUES(:p0)";
$stmt = $conn->prepare($query);

View file

@ -8,8 +8,7 @@ Test getting invalid attributes
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$conn = connect("", array(), "silent");
@$conn->getAttribute(PDO::ATTR_FETCH_TABLE_NAMES);
print_r(($conn->errorInfo())[2]);

View file

@ -9,18 +9,9 @@ In Azure for this test to pass do not specify any particular database when conne
--FILE--
<?php
require_once("MsSetup.inc");
require_once("MsCommon_mid-refactor.inc");
$dsn = "sqlsrv:Server=$server;ConnectionPooling=false;";
// get DSN information for Column Encryption
if ($keystore != "none") {
$dsn .= "ColumnEncryption=Enabled;";
}
if ($keystore == "ksp") {
require('AE_Ksp.inc');
$ksp_path = getKSPPath();
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
}
$dsn = getDSN($server, null, "ConnectionPooling=false;");
try {
// Test 1
$conn = new PDO($dsn, "test_password", "! ;4triou");

View file

@ -8,8 +8,7 @@ require_once("MsCommon_mid-refactor.inc");
try {
$connection_options = array();
$connection_options[PDO::ATTR_STRINGIFY_FETCHES] = true;
$cnn = connect("", $connection_options);
$cnn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
$cnn = connect("", $connection_options, "silent");
$pdo_options = array();
$pdo_options[PDO::ATTR_CURSOR] = PDO::CURSOR_SCROLL;
@ -55,7 +54,7 @@ try {
//EMULATE PREPARE with no bind param options; expects an error
print_r("Prepare with emulate prepare and no bindparam options:\n");
rewind($p);
$st = $cnn->prepare("INSERT INTO $tbname VALUES(:p0)", $pdo_options);
$st->bindParam(':p0', $p, PDO::PARAM_LOB);
$st->execute();

View file

@ -7,8 +7,7 @@ prepare with emulate prepare and binding integer
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$conn = connect("", array(), "silent");
$tableName = "date_types";
createTable($conn, $tableName, array("c1_datetime" => "datetime", "c2_nvarchar" => "nvarchar(20)"));

View file

@ -7,8 +7,7 @@ prepare with emulate prepare and binding integer
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$conn = connect("", array(), "silent");
$tableName = "number_types";
if (!isColEncrypted()) {

View file

@ -1,17 +1,16 @@
<?php
if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv'))
if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv')) {
die("PDO driver cannot be loaded; skipping test.\n");
require_once( "MsSetup.inc" );
require_once( "MsCommon_mid-refactor.inc" );
}
$conn = new PDO( "sqlsrv:server = $server;", $uid, $pwd );
if( ! $conn )
{
echo( "Error: could not connect during SKIPIF!" );
require_once("MsSetup.inc");
require_once("MsCommon_mid-refactor.inc");
$dsn = getDSN($server, null);
$conn = new PDO($dsn, $uid, $pwd);
if (! $conn) {
echo("Error: could not connect during SKIPIF!");
} elseif (isColEncrypted() && !isAEQualified($conn)) {
die("skip - AE feature not supported in the current environment.");
}
else if(isColEncrypted() && !isAEQualified($conn))
{
die( "skip - AE feature not supported in the current environment." );
}
?>