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
|
||||
$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)");
|
||||
$tsql = "INSERT INTO [$tableName] (id, class, value) VALUES(:id, :class, :value)";
|
||||
$tsql = "INSERT INTO [$tableName] (class, value) VALUES(:class, :value)";
|
||||
|
||||
$id = 0;
|
||||
$class = 0;
|
||||
|
@ -25,22 +25,18 @@ try {
|
|||
|
||||
// Prepare insert query$
|
||||
$stmt1 = $conn1->prepare($tsql);
|
||||
bindParam(1, $stmt1, ':id', $id);
|
||||
bindParam(2, $stmt1, ':class', $class);
|
||||
bindParam(3, $stmt1, ':value', $value);
|
||||
bindParam(1, $stmt1, ':class', $class);
|
||||
bindParam(2, $stmt1, ':value', $value);
|
||||
|
||||
// Insert test rows
|
||||
$id = 1;
|
||||
$class = 4;
|
||||
$value = '2011';
|
||||
execStmt(1, $stmt1);
|
||||
|
||||
$id = 2;
|
||||
$class = 5;
|
||||
$value = 'Sat, 20 Mar 10 21:29:13 -0600';
|
||||
execStmt(2, $stmt1);
|
||||
|
||||
$id = 3;
|
||||
$class = 6;
|
||||
$value = 'Fri, 07 May 10 11:35:32 -0600';
|
||||
execStmt(3, $stmt1);
|
||||
|
@ -50,7 +46,7 @@ try {
|
|||
// Check data
|
||||
$id = 0;
|
||||
$value = '';
|
||||
$tsql = "SELECT id, value FROM [$tableName]";
|
||||
$tsql = "SELECT id, value FROM [$tableName] ORDER BY id";
|
||||
$stmt2 = $conn1->query($tsql);
|
||||
bindColumn(1, $stmt2, $id, $value);
|
||||
while ($stmt2->fetch(PDO::FETCH_BOUND)) {
|
||||
|
|
|
@ -12,9 +12,15 @@ function testSimpleSelect($conn, $tableName)
|
|||
{
|
||||
$count = 0;
|
||||
|
||||
$stmt = $conn->prepare("SELECT ? = COUNT(* ) FROM $tableName");
|
||||
$stmt->bindParam(1, $count, PDO::PARAM_INT, 4);
|
||||
$stmt->execute();
|
||||
if (!isAEConnected()) {
|
||||
$stmt = $conn->prepare("SELECT ? = COUNT(* ) FROM $tableName");
|
||||
$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";
|
||||
|
||||
$value = 'xx';
|
||||
|
@ -65,12 +71,15 @@ try {
|
|||
dropTable($conn, $tableName);
|
||||
unset($conn);
|
||||
} 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
|
||||
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
|
||||
|
|
|
@ -44,8 +44,12 @@ if (isAEConnected()) {
|
|||
$option[PDO::ATTR_EMULATE_PREPARES] = false;
|
||||
}
|
||||
|
||||
$s = $db->prepare("SELECT :prefix + TITLE FROM cd_info GROUP BY :prefix + TITLE", $option);
|
||||
$s->bindValue(':prefix', "");
|
||||
if (!isAEConnected()) {
|
||||
$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();
|
||||
|
||||
$param_titles = array();
|
||||
|
|
|
@ -70,9 +70,21 @@ try {
|
|||
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
||||
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
print_r($row);
|
||||
if ($stmt->rowCount() == 0) {
|
||||
print_r("No results for this query\n");
|
||||
// Linux supports binding UTF8 data with SQLSRV_ENCODING_SYSTEM since the default encoding in Linux is UTF8
|
||||
$success = true;
|
||||
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
|
||||
|
@ -110,6 +122,6 @@ Array
|
|||
[age] => 30
|
||||
)
|
||||
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:
|
||||
No results for this query
|
||||
|
|
|
@ -72,8 +72,11 @@ try {
|
|||
dropTable($conn, $tbname);
|
||||
unset($conn);
|
||||
} catch (PDOexception $e) {
|
||||
print_r(($e->errorInfo)[2]);
|
||||
echo "\n";
|
||||
$error = $e->getMessage();
|
||||
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--
|
||||
|
@ -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.
|
||||
Statement with emulate prepare on does not support output or input_output parameters.
|
||||
|
|
Loading…
Reference in a new issue