diff --git a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc index 219693a5..61b4cde8 100644 --- a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc +++ b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc @@ -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 . ", "; } diff --git a/test/functional/pdo_sqlsrv/pdo_018_next_result_set.phpt b/test/functional/pdo_sqlsrv/pdo_018_next_result_set.phpt index 579df9e7..ea48f279 100644 --- a/test/functional/pdo_sqlsrv/pdo_018_next_result_set.phpt +++ b/test/functional/pdo_sqlsrv/pdo_018_next_result_set.phpt @@ -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) { diff --git a/test/functional/pdo_sqlsrv/pdo_019_next_result_set_pooling.phpt b/test/functional/pdo_sqlsrv/pdo_019_next_result_set_pooling.phpt index aaac8412..6f36216c 100644 --- a/test/functional/pdo_sqlsrv/pdo_019_next_result_set_pooling.phpt +++ b/test/functional/pdo_sqlsrv/pdo_019_next_result_set_pooling.phpt @@ -4,11 +4,11 @@ Moves the cursor to the next result set with pooling enabled --FILE-- 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"; + } } } diff --git a/test/functional/pdo_sqlsrv/pdo_022_xml_bind_value.phpt b/test/functional/pdo_sqlsrv/pdo_022_xml_bind_value.phpt index ddd1512a..64ffa50b 100644 --- a/test/functional/pdo_sqlsrv/pdo_022_xml_bind_value.phpt +++ b/test/functional/pdo_sqlsrv/pdo_022_xml_bind_value.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_033_binary_unicode.phpt b/test/functional/pdo_sqlsrv/pdo_033_binary_unicode.phpt index 63748e05..d20b7f76 100644 --- a/test/functional/pdo_sqlsrv/pdo_033_binary_unicode.phpt +++ b/test/functional/pdo_sqlsrv/pdo_033_binary_unicode.phpt @@ -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(); diff --git a/test/functional/pdo_sqlsrv/pdo_040_error_information.phpt b/test/functional/pdo_sqlsrv/pdo_040_error_information.phpt index 388278b4..4081505d 100644 --- a/test/functional/pdo_sqlsrv/pdo_040_error_information.phpt +++ b/test/functional/pdo_sqlsrv/pdo_040_error_information.phpt @@ -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); } diff --git a/test/functional/pdo_sqlsrv/pdo_065_construct_persistent.phpt b/test/functional/pdo_sqlsrv/pdo_065_construct_persistent.phpt index 6fd04614..58bc4a73 100644 --- a/test/functional/pdo_sqlsrv/pdo_065_construct_persistent.phpt +++ b/test/functional/pdo_sqlsrv/pdo_065_construct_persistent.phpt @@ -5,23 +5,28 @@ Exception is thrown if the unsupported attribute ATTR_PERSISTENT is put into the --FILE-- 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 diff --git a/test/functional/pdo_sqlsrv/pdo_092_emulate_prepare_statement_utf8.phpt b/test/functional/pdo_sqlsrv/pdo_092_emulate_prepare_statement_utf8.phpt index 3c60cd0f..24ab4c15 100644 --- a/test/functional/pdo_sqlsrv/pdo_092_emulate_prepare_statement_utf8.phpt +++ b/test/functional/pdo_sqlsrv/pdo_092_emulate_prepare_statement_utf8.phpt @@ -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 \ No newline at end of file +FOUND: 가각sample2 diff --git a/test/functional/pdo_sqlsrv/pdo_140_emulate_prepare_mix_binary.phpt b/test/functional/pdo_sqlsrv/pdo_140_emulate_prepare_mix_binary.phpt index 3c790c19..a7420878 100644 --- a/test/functional/pdo_sqlsrv/pdo_140_emulate_prepare_mix_binary.phpt +++ b/test/functional/pdo_sqlsrv/pdo_140_emulate_prepare_mix_binary.phpt @@ -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]( diff --git a/test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq_2.phpt b/test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq_2.phpt index 8ad9dc92..ba8c22dc 100644 --- a/test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq_2.phpt +++ b/test/functional/pdo_sqlsrv/pdo_278_lastinsertid_seq_2.phpt @@ -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) diff --git a/test/functional/pdo_sqlsrv/pdo_336_pho_exec_empty_result_set_error.phpt b/test/functional/pdo_sqlsrv/pdo_336_pho_exec_empty_result_set_error.phpt index d30076ad..fab0cb77 100644 --- a/test/functional/pdo_sqlsrv/pdo_336_pho_exec_empty_result_set_error.phpt +++ b/test/functional/pdo_sqlsrv/pdo_336_pho_exec_empty_result_set_error.phpt @@ -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") { diff --git a/test/functional/pdo_sqlsrv/pdo_378_out_param_error.phpt b/test/functional/pdo_sqlsrv/pdo_378_out_param_error.phpt index 31e2fb25..9d1832cd 100644 --- a/test/functional/pdo_sqlsrv/pdo_378_out_param_error.phpt +++ b/test/functional/pdo_sqlsrv/pdo_378_out_param_error.phpt @@ -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-- @@ -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) { diff --git a/test/functional/pdo_sqlsrv/pdo_connection_quote.phpt b/test/functional/pdo_sqlsrv/pdo_connection_quote.phpt index 31a34139..0369276d 100644 --- a/test/functional/pdo_sqlsrv/pdo_connection_quote.phpt +++ b/test/functional/pdo_sqlsrv/pdo_connection_quote.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_errorMode.phpt b/test/functional/pdo_sqlsrv/pdo_errorMode.phpt index 9f317a09..b7eec388 100644 --- a/test/functional/pdo_sqlsrv/pdo_errorMode.phpt +++ b/test/functional/pdo_sqlsrv/pdo_errorMode.phpt @@ -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); } diff --git a/test/functional/pdo_sqlsrv/pdo_errorinfo_emulateprepare.phpt b/test/functional/pdo_sqlsrv/pdo_errorinfo_emulateprepare.phpt index b8cdeac2..598fd3c4 100644 --- a/test/functional/pdo_sqlsrv/pdo_errorinfo_emulateprepare.phpt +++ b/test/functional/pdo_sqlsrv/pdo_errorinfo_emulateprepare.phpt @@ -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]+ \ No newline at end of file +Warning: PDOStatement::bindParam\(\): SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+ diff --git a/test/functional/pdo_sqlsrv/pdo_exec_invalid_query.phpt b/test/functional/pdo_sqlsrv/pdo_exec_invalid_query.phpt index 99d1f171..f91e6ac3 100644 --- a/test/functional/pdo_sqlsrv/pdo_exec_invalid_query.phpt +++ b/test/functional/pdo_sqlsrv/pdo_exec_invalid_query.phpt @@ -6,8 +6,8 @@ direct execution of an invalid query 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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_binary.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_binary.phpt index 7c7fb324..51cc6147 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_binary.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_binary.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_char.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_char.phpt index 2e219734..0e8e61e6 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_char.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_char.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_datetime.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_datetime.phpt index 6038b5dd..9c85317f 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_datetime.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_datetime.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal.phpt index 83faf3e4..b9243ce1 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal_bindColumn_int.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal_bindColumn_int.phpt index 7f4ae622..50457ed1 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal_bindColumn_int.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_decimal_bindColumn_int.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float.phpt index e4cceb94..101958fa 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float_bindColumn_lob.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float_bindColumn_lob.phpt index 25bd2a13..4239aef5 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float_bindColumn_lob.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_float_bindColumn_lob.phpt @@ -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(); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int.phpt index 374940c0..4ae0fe74 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int_bindColumn_int.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int_bindColumn_int.phpt index b46cde8a..95ef8d9e 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int_bindColumn_int.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_int_bindColumn_int.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money.phpt index f8f4dcba..5c327fb0 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money.phpt @@ -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)"; diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money_bindColumn_int.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money_bindColumn_int.phpt index 7cb7ead8..afda28dd 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money_bindColumn_int.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_money_bindColumn_int.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_unicode.phpt b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_unicode.phpt index c0ad4396..6379438e 100644 --- a/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_unicode.phpt +++ b/test/functional/pdo_sqlsrv/pdo_fetch_cursorBuffered_unicode.phpt @@ -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); diff --git a/test/functional/pdo_sqlsrv/pdo_get_attr_invalid.phpt b/test/functional/pdo_sqlsrv/pdo_get_attr_invalid.phpt index fe1482b6..5a5a718b 100644 --- a/test/functional/pdo_sqlsrv/pdo_get_attr_invalid.phpt +++ b/test/functional/pdo_sqlsrv/pdo_get_attr_invalid.phpt @@ -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]); diff --git a/test/functional/pdo_sqlsrv/pdo_passwords.phpt b/test/functional/pdo_sqlsrv/pdo_passwords.phpt index f0534ede..c672fc95 100644 --- a/test/functional/pdo_sqlsrv/pdo_passwords.phpt +++ b/test/functional/pdo_sqlsrv/pdo_passwords.phpt @@ -9,18 +9,9 @@ In Azure for this test to pass do not specify any particular database when conne --FILE-- 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(); diff --git a/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_datetime.phpt b/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_datetime.phpt index cfa4f13e..368aa26a 100644 --- a/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_datetime.phpt +++ b/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_datetime.phpt @@ -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)")); diff --git a/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_decimal.phpt b/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_decimal.phpt index 890734fa..6af8cff6 100644 --- a/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_decimal.phpt +++ b/test/functional/pdo_sqlsrv/pdo_prepare_emulatePrepare_decimal.phpt @@ -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()) { diff --git a/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc b/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc index a1c2677e..4859bf32 100644 --- a/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc +++ b/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc @@ -1,17 +1,16 @@