fix tests related to having parameter markers in the select list
This commit is contained in:
parent
35146b77d2
commit
57d7400f2c
|
@ -15,9 +15,9 @@ try {
|
||||||
|
|
||||||
// Prepare test table
|
// Prepare test table
|
||||||
$tableName = "pdo_test_table";
|
$tableName = "pdo_test_table";
|
||||||
createTable($conn1, $tableName, array("id" => "int", "class" => "int", "value" => "char(32)"));
|
createTable($conn1, $tableName, array(new ColumnMeta("int", "id", "IDENTITY NOT NULL"), "class" => "int", "value" => "char(32)"));
|
||||||
$conn1->exec("CREATE CLUSTERED INDEX [idx_test_int] ON $tableName (id)");
|
$conn1->exec("CREATE CLUSTERED INDEX [idx_test_int] ON $tableName (id)");
|
||||||
$tsql = "INSERT INTO [$tableName] (id, class, value) VALUES(:id, :class, :value)";
|
$tsql = "INSERT INTO [$tableName] (class, value) VALUES(:class, :value)";
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
$class = 0;
|
$class = 0;
|
||||||
|
@ -25,22 +25,18 @@ try {
|
||||||
|
|
||||||
// Prepare insert query$
|
// Prepare insert query$
|
||||||
$stmt1 = $conn1->prepare($tsql);
|
$stmt1 = $conn1->prepare($tsql);
|
||||||
bindParam(1, $stmt1, ':id', $id);
|
bindParam(1, $stmt1, ':class', $class);
|
||||||
bindParam(2, $stmt1, ':class', $class);
|
bindParam(2, $stmt1, ':value', $value);
|
||||||
bindParam(3, $stmt1, ':value', $value);
|
|
||||||
|
|
||||||
// Insert test rows
|
// Insert test rows
|
||||||
$id = 1;
|
|
||||||
$class = 4;
|
$class = 4;
|
||||||
$value = '2011';
|
$value = '2011';
|
||||||
execStmt(1, $stmt1);
|
execStmt(1, $stmt1);
|
||||||
|
|
||||||
$id = 2;
|
|
||||||
$class = 5;
|
$class = 5;
|
||||||
$value = 'Sat, 20 Mar 10 21:29:13 -0600';
|
$value = 'Sat, 20 Mar 10 21:29:13 -0600';
|
||||||
execStmt(2, $stmt1);
|
execStmt(2, $stmt1);
|
||||||
|
|
||||||
$id = 3;
|
|
||||||
$class = 6;
|
$class = 6;
|
||||||
$value = 'Fri, 07 May 10 11:35:32 -0600';
|
$value = 'Fri, 07 May 10 11:35:32 -0600';
|
||||||
execStmt(3, $stmt1);
|
execStmt(3, $stmt1);
|
||||||
|
@ -50,7 +46,7 @@ try {
|
||||||
// Check data
|
// Check data
|
||||||
$id = 0;
|
$id = 0;
|
||||||
$value = '';
|
$value = '';
|
||||||
$tsql = "SELECT id, value FROM [$tableName]";
|
$tsql = "SELECT id, value FROM [$tableName] ORDER BY id";
|
||||||
$stmt2 = $conn1->query($tsql);
|
$stmt2 = $conn1->query($tsql);
|
||||||
bindColumn(1, $stmt2, $id, $value);
|
bindColumn(1, $stmt2, $id, $value);
|
||||||
while ($stmt2->fetch(PDO::FETCH_BOUND)) {
|
while ($stmt2->fetch(PDO::FETCH_BOUND)) {
|
||||||
|
|
|
@ -12,9 +12,15 @@ function testSimpleSelect($conn, $tableName)
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT ? = COUNT(* ) FROM $tableName");
|
if (!isAEConnected()) {
|
||||||
$stmt->bindParam(1, $count, PDO::PARAM_INT, 4);
|
$stmt = $conn->prepare("SELECT ? = COUNT(* ) FROM $tableName");
|
||||||
$stmt->execute();
|
$stmt->bindParam(1, $count, PDO::PARAM_INT, 4);
|
||||||
|
$stmt->execute();
|
||||||
|
} else {
|
||||||
|
$stmt = $conn->prepare("SELECT COUNT(*) FROM $tableName");
|
||||||
|
$stmt->execute();
|
||||||
|
$count = $stmt->fetch()[0];
|
||||||
|
}
|
||||||
echo "Number of rows: $count\n";
|
echo "Number of rows: $count\n";
|
||||||
|
|
||||||
$value = 'xx';
|
$value = 'xx';
|
||||||
|
@ -65,12 +71,15 @@ try {
|
||||||
dropTable($conn, $tableName);
|
dropTable($conn, $tableName);
|
||||||
unset($conn);
|
unset($conn);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
$error = $e->getMessage();
|
||||||
|
if (!(!isAEConnected() && strpos($error, "Implicit conversion from data type sql_variant to nvarchar(max) is not allowed. Use the CONVERT function to run this query.") !== false) &&
|
||||||
|
!(isAEConnected() && strpos($error, "Invalid Descriptor Index") !== false)) {
|
||||||
|
echo $error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "\nDone\n";
|
echo "Done\n";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTREGEX--
|
--EXPECT--
|
||||||
Number of rows: 1
|
Number of rows: 1
|
||||||
SQLSTATE\[42000\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type sql_variant to nvarchar\(max\) is not allowed. Use the CONVERT function to run this query.
|
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -44,8 +44,12 @@ if (isAEConnected()) {
|
||||||
$option[PDO::ATTR_EMULATE_PREPARES] = false;
|
$option[PDO::ATTR_EMULATE_PREPARES] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$s = $db->prepare("SELECT :prefix + TITLE FROM cd_info GROUP BY :prefix + TITLE", $option);
|
if (!isAEConnected()) {
|
||||||
$s->bindValue(':prefix', "");
|
$s = $db->prepare("SELECT :prefix + TITLE FROM cd_info GROUP BY :prefix + TITLE", $option);
|
||||||
|
$s->bindValue(':prefix', "");
|
||||||
|
} else {
|
||||||
|
$s = $db->prepare("SELECT TITLE FROM cd_info GROUP BY TITLE", $option);
|
||||||
|
}
|
||||||
$s->execute();
|
$s->execute();
|
||||||
|
|
||||||
$param_titles = array();
|
$param_titles = array();
|
||||||
|
|
|
@ -70,9 +70,21 @@ try {
|
||||||
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
||||||
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
print_r($row);
|
// Linux supports binding UTF8 data with SQLSRV_ENCODING_SYSTEM since the default encoding in Linux is UTF8
|
||||||
if ($stmt->rowCount() == 0) {
|
$success = true;
|
||||||
print_r("No results for this query\n");
|
if (!(strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN') && isAEConnected()) {
|
||||||
|
if ($row['name'] != "가각" || $row['status'] != 1 || $row['age'] != 30) {
|
||||||
|
print_r("Incorrect results retrieved.\n");
|
||||||
|
$success = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($stmt->rowCount() != 0) {
|
||||||
|
print_r("Binding UTF8 data when encoding is SQLSRV_ENCODING_SYSTEM should not work.\n");
|
||||||
|
$success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($success) {
|
||||||
|
print_r("Binding UTF8 data with SQLSRV_ENCODING_SYSTEM is tested successfully.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
//with emulate prepare and encoding SQLSRV_ENCODING_BINARY
|
||||||
|
@ -110,6 +122,6 @@ Array
|
||||||
[age] => 30
|
[age] => 30
|
||||||
)
|
)
|
||||||
Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:
|
Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:
|
||||||
No results for this query
|
Binding UTF8 data with SQLSRV_ENCODING_SYSTEM is tested successfully.
|
||||||
Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:
|
Prepare with emulate prepare and encoding SQLSRV_ENCODING_BINARY:
|
||||||
No results for this query
|
No results for this query
|
||||||
|
|
|
@ -72,8 +72,11 @@ try {
|
||||||
dropTable($conn, $tbname);
|
dropTable($conn, $tbname);
|
||||||
unset($conn);
|
unset($conn);
|
||||||
} catch (PDOexception $e) {
|
} catch (PDOexception $e) {
|
||||||
print_r(($e->errorInfo)[2]);
|
$error = $e->getMessage();
|
||||||
echo "\n";
|
if (!(!isAEConnected() && strpos($error, "Statement with emulate prepare on does not support output or input_output parameters.") !== false) &&
|
||||||
|
!(isAEConnected() && strpos($error, "Invalid Descriptor Index") !== false)) {
|
||||||
|
echo $error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -83,4 +86,3 @@ outValue is the same as inValue.
|
||||||
outValue is the same as inValue.
|
outValue is the same as inValue.
|
||||||
outValue is the same as inValue.
|
outValue is the same as inValue.
|
||||||
outValue is the same as inValue.
|
outValue is the same as inValue.
|
||||||
Statement with emulate prepare on does not support output or input_output parameters.
|
|
||||||
|
|
Loading…
Reference in a new issue