apply review changes
This commit is contained in:
parent
d10af00511
commit
318e5312c2
|
@ -75,7 +75,7 @@ try {
|
|||
}
|
||||
|
||||
// Close connection
|
||||
//dropTable($conn, $tableName);
|
||||
dropTable($conn, $tableName);
|
||||
unset($stmt);
|
||||
unset($con);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
Insert binary HEX data then fetch it back as string
|
||||
--DESCRIPTION--
|
||||
Insert binary HEX data into an nvarchar field then read it back as UTF-8 string
|
||||
Insert binary HEX data into an nvarchar field then read it back as UTF-8 string
|
||||
--SKIPIF--
|
||||
<?php require('skipif_mid-refactor.inc'); ?>
|
||||
--FILE--
|
||||
|
@ -16,12 +16,15 @@ try {
|
|||
$tableName = 'pdo_033test';
|
||||
createTable($conn, $tableName, array("c1" => "nvarchar(100)"));
|
||||
|
||||
$input = pack( "H*", '49006427500048005000' ); // I'LOVE_SYMBOL'PHP
|
||||
$input = pack("H*", '49006427500048005000'); // I'LOVE_SYMBOL'PHP
|
||||
$result;
|
||||
$stmt = insertRow($conn, $tableName, array("c1" => new BindParamOp(1, $input, "PDO::PARAM_STR", 0, "PDO::SQLSRV_ENCODING_BINARY")), "prepareBindParam", $result);
|
||||
|
||||
|
||||
if (!$result) {
|
||||
echo "Failed to insert!\n";
|
||||
dropTable($conn, $tableName);
|
||||
unset($stmt);
|
||||
unset($conn);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -36,10 +39,10 @@ try {
|
|||
} catch (PDOException $e) {
|
||||
var_dump($e->errorInfo);
|
||||
}
|
||||
|
||||
|
||||
print "Done";
|
||||
?>
|
||||
|
||||
--EXPECT--
|
||||
I❤PHP
|
||||
Done
|
||||
Done
|
||||
|
|
|
@ -9,7 +9,7 @@ require_once("MsCommon_mid-refactor.inc");
|
|||
try {
|
||||
// Connect
|
||||
// set errmode to silent to compare sqlstates in the test
|
||||
$conn = connect("", array(), "silent");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
// Create table
|
||||
$tableName = 'pdo_040test';
|
||||
|
|
|
@ -5,6 +5,7 @@ Exception is thrown if the unsupported attribute ATTR_PERSISTENT is put into the
|
|||
--FILE--
|
||||
<?php
|
||||
require_once("MsSetup.inc");
|
||||
require_once("MsCommon_mid-refactor.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
|
||||
|
@ -12,25 +13,15 @@ require_once("MsSetup.inc");
|
|||
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") {
|
||||
$dsn .= "ColumnEncryption=Enabled;";
|
||||
}
|
||||
if ($keystore == "ksp") {
|
||||
require_once('AE_Ksp.inc');
|
||||
$ksp_path = getKSPPath();
|
||||
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
|
||||
}
|
||||
$dsn = getDSN($server, $databaseName);
|
||||
$attr = array(PDO::ATTR_PERSISTENT => true);
|
||||
$conn = new PDO($dsn, $uid, $pwd, $attr);
|
||||
|
||||
//free the connection
|
||||
unset($conn);
|
||||
} catch (PDOException $e) {
|
||||
echo "Exception from unsupported attribute (ATTR_PERSISTENT) is caught\n";
|
||||
}
|
||||
try {
|
||||
require_once("MsCommon_mid-refactor.inc");
|
||||
echo "\nTesting new connection after exception thrown in previous connection...\n";
|
||||
$tableName1 = getTableName('tab1');
|
||||
$conn = connect();
|
||||
|
@ -39,7 +30,7 @@ try {
|
|||
|
||||
$result = selectRow($conn, $tableName1, "PDO::FETCH_ASSOC");
|
||||
if ($result['c1'] == 1 && $result['c2'] == 'column2') {
|
||||
echo "Test successfully completed";
|
||||
echo "Test successfully completed\n";
|
||||
}
|
||||
//free the statement and connection
|
||||
dropTable($conn, $tableName);
|
||||
|
|
|
@ -8,7 +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("", array(), "silent");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
$output1 = $conn->quote("1'2'3'4'5'6'7'8", PDO::PARAM_INT);
|
||||
var_dump($output1);
|
||||
|
|
|
@ -19,14 +19,14 @@ function testException()
|
|||
|
||||
function testWarning()
|
||||
{
|
||||
$db = connect("", array(), "warning");
|
||||
$db = connect("", array(), PDO::ERRMODE_WARNING);
|
||||
$sql = "SELECT * FROM temp_table";
|
||||
$q = $db->query($sql);
|
||||
}
|
||||
|
||||
function testSilent()
|
||||
{
|
||||
$db = connect("", array(), "silent");
|
||||
$db = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
$sql = "SELECT * FROM temp_table";
|
||||
$q = $db->query($sql);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ require_once("MsCommon_mid-refactor.inc");
|
|||
try {
|
||||
// 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");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
//drop, create and insert
|
||||
$tbname = "test_table";
|
||||
|
|
|
@ -7,7 +7,7 @@ direct execution of an invalid query
|
|||
require_once("MsCommon_mid-refactor.inc");
|
||||
|
||||
// set ERRMODE to silent to return in errorCode in the test
|
||||
$conn = connect("", array(), "silent");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
$tbname = "table1";
|
||||
dropTable($conn, $tbname);
|
||||
|
|
|
@ -8,7 +8,7 @@ Test getting invalid attributes
|
|||
require_once("MsCommon_mid-refactor.inc");
|
||||
|
||||
try {
|
||||
$conn = connect("", array(), "silent");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
@$conn->getAttribute(PDO::ATTR_FETCH_TABLE_NAMES);
|
||||
print_r(($conn->errorInfo())[2]);
|
||||
|
|
|
@ -8,7 +8,7 @@ require_once("MsCommon_mid-refactor.inc");
|
|||
try {
|
||||
$connection_options = array();
|
||||
$connection_options[PDO::ATTR_STRINGIFY_FETCHES] = true;
|
||||
$cnn = connect("", $connection_options, "silent");
|
||||
$cnn = connect("", $connection_options, PDO::ERRMODE_SILENT);
|
||||
|
||||
$pdo_options = array();
|
||||
$pdo_options[PDO::ATTR_CURSOR] = PDO::CURSOR_SCROLL;
|
||||
|
|
|
@ -7,7 +7,7 @@ prepare with emulate prepare and binding integer
|
|||
require_once("MsCommon_mid-refactor.inc");
|
||||
|
||||
try {
|
||||
$conn = connect("", array(), "silent");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
$tableName = "date_types";
|
||||
createTable($conn, $tableName, array("c1_datetime" => "datetime", "c2_nvarchar" => "nvarchar(20)"));
|
||||
|
|
|
@ -7,7 +7,7 @@ prepare with emulate prepare and binding integer
|
|||
require_once("MsCommon_mid-refactor.inc");
|
||||
|
||||
try {
|
||||
$conn = connect("", array(), "silent");
|
||||
$conn = connect("", array(), PDO::ERRMODE_SILENT);
|
||||
|
||||
$tableName = "number_types";
|
||||
if (!isColEncrypted()) {
|
||||
|
@ -79,7 +79,8 @@ try {
|
|||
var_dump($e->errorInfo);
|
||||
}
|
||||
?>
|
||||
|
||||
--XFAIL--
|
||||
Bug with column encryption: Insertion fails if input has more decimal places than the column definition
|
||||
--EXPECT--
|
||||
Prepare without emulate prepare:
|
||||
Array
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
--TEST--
|
||||
Test warnings on connection and statement levels
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
<?php require('skipif_mid-refactor.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
try{
|
||||
require_once("MsSetup.inc");
|
||||
try {
|
||||
require_once("MsCommon_mid-refactor.inc");
|
||||
|
||||
$conn = new PDO( "sqlsrv:Server=$server; database = $databaseName ", $uid, $pwd);
|
||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
|
||||
|
||||
$conn = connect("", array(), PDO::ERRMODE_WARNING);
|
||||
// raise a warning in connection
|
||||
$conn->getAttribute( PDO::ATTR_TIMEOUT );
|
||||
|
||||
$conn->exec("IF OBJECT_ID('table1', 'U') IS NOT NULL DROP TABLE table1");
|
||||
|
||||
$conn->getAttribute(PDO::ATTR_TIMEOUT);
|
||||
|
||||
$tbname = "table1";
|
||||
dropTable($conn, $tbname);
|
||||
|
||||
// raise a warning in statement
|
||||
$statement = $conn->prepare("CRATE TABLE table1(id INT NOT NULL PRIMARY KEY, val VARCHAR(10)) ");
|
||||
$statement = $conn->prepare("CRATE TABLE table1(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))");
|
||||
$statement->execute();
|
||||
|
||||
$statement = NULL;
|
||||
$conn = NULL;
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
var_dump( $e->errorInfo );
|
||||
unset($statement);
|
||||
unset($conn);
|
||||
} catch (PDOException $e) {
|
||||
var_dump($e->errorInfo);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
@ -35,4 +33,4 @@ Error Message: An unsupported attribute was designated on the PDO object\.
|
|||
|
||||
Warning: PDO::getAttribute\(\): SQLSTATE\[IM001\]: Driver does not support this function: driver does not support that attribute in .+(\/|\\)pdo_warnings\.php on line [0-9]+
|
||||
|
||||
Warning: PDOStatement::execute\(\): SQLSTATE\[42000\]: Syntax error or access violation: 156 \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Incorrect syntax near the keyword 'TABLE'\. in .+(\/|\\)pdo_warnings\.php on line [0-9]+
|
||||
Warning: PDOStatement::execute\(\): SQLSTATE\[42000\]: Syntax error or access violation: 156 \[Microsoft\]\[ODBC Driver [0-9]+ for SQL Server\]\[SQL Server\]Incorrect syntax near the keyword 'TABLE'\. in .+(\/|\\)pdo_warnings\.php on line [0-9]+
|
||||
|
|
Loading…
Reference in a new issue