2017-05-04 00:04:17 +03:00
|
|
|
--TEST--
|
|
|
|
PDO Bind Param Test
|
|
|
|
--DESCRIPTION--
|
|
|
|
Verification for "PDOStatement::bindParam()".
|
|
|
|
--ENV--
|
|
|
|
PHPT_EXEC=true
|
|
|
|
--SKIPIF--
|
2017-12-01 01:37:25 +03:00
|
|
|
<?php require_once('skipif_mid-refactor.inc'); ?>
|
2017-05-04 00:04:17 +03:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2017-12-01 01:37:25 +03:00
|
|
|
require_once("MsCommon_mid-refactor.inc");
|
2017-05-04 00:04:17 +03:00
|
|
|
|
2017-12-01 01:37:25 +03:00
|
|
|
try {
|
|
|
|
$conn1 = connect();
|
2017-05-04 00:04:17 +03:00
|
|
|
|
|
|
|
// Prepare test table
|
|
|
|
$dataCols = "id, name";
|
2017-12-01 01:37:25 +03:00
|
|
|
$tableName = "pdo_test_table";
|
|
|
|
createTable($conn1, $tableName, array("id" => "int", "name" => "varchar(20)"));
|
|
|
|
$conn1->exec("CREATE CLUSTERED INDEX [idx_test_int] ON $tableName (id)");
|
2017-05-04 00:04:17 +03:00
|
|
|
|
|
|
|
// Insert test data
|
2017-12-01 01:37:25 +03:00
|
|
|
if (isColEncrypted()) {
|
|
|
|
$stmt1 = $conn1->prepare("INSERT INTO [$tableName] ($dataCols) VALUES(:id, :name)");
|
|
|
|
$id = 0;
|
|
|
|
$stmt1->bindParam(':id', $id);
|
|
|
|
} else {
|
|
|
|
$stmt1 = $conn1->prepare("INSERT INTO [$tableName] ($dataCols) VALUES(0, :name)");
|
|
|
|
}
|
|
|
|
$name = null;
|
2017-05-04 00:04:17 +03:00
|
|
|
$before_bind = $name;
|
|
|
|
$stmt1->bindParam(':name', $name);
|
|
|
|
|
|
|
|
// Check that bindParam does not modify parameter
|
2017-12-01 01:37:25 +03:00
|
|
|
if ($name !== $before_bind) {
|
2017-05-04 00:04:17 +03:00
|
|
|
echo "bind: fail\n";
|
2017-12-01 01:37:25 +03:00
|
|
|
} else {
|
2017-05-04 00:04:17 +03:00
|
|
|
echo "bind: success\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
var_dump($stmt1->execute());
|
|
|
|
unset($stmt1);
|
|
|
|
|
|
|
|
// Retrieve test data
|
2017-12-01 01:37:25 +03:00
|
|
|
if (isColEncrypted()) {
|
|
|
|
$stmt1 = $conn1->prepare("SELECT name FROM [$tableName] WHERE id = ?");
|
|
|
|
$id = 0;
|
|
|
|
$stmt1->bindParam(1, $id);
|
|
|
|
$stmt1->execute();
|
|
|
|
} else {
|
|
|
|
$stmt1 = $conn1->query("SELECT name FROM [$tableName] WHERE id = 0");
|
|
|
|
}
|
2017-05-04 00:04:17 +03:00
|
|
|
var_dump($stmt1->fetchColumn());
|
|
|
|
|
|
|
|
// Cleanup
|
2017-12-01 01:37:25 +03:00
|
|
|
dropTable($conn1, $tableName);
|
|
|
|
unset($stmt1);
|
|
|
|
unset($conn1);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
echo $e->getMessage();
|
2017-05-04 00:04:17 +03:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
bind: success
|
|
|
|
bool(true)
|
|
|
|
NULL
|