msphpsql/test/functional/pdo_sqlsrv/PDO63_BindParam1.phpt

67 строки
1.6 KiB
Plaintext
Исходник Постоянная ссылка Обычный вид История

2017-05-04 00:04:17 +03:00
--TEST--
PDO Bind Param Test
--DESCRIPTION--
Verification for "PDOStatement::bindParam()".
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require_once('skipif_mid-refactor.inc'); ?>
2017-05-04 00:04:17 +03:00
--FILE--
<?php
require_once("MsCommon_mid-refactor.inc");
2017-05-04 00:04:17 +03:00
try {
$conn1 = connect();
2017-05-04 00:04:17 +03:00
// Prepare test table
$dataCols = "id, name";
$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
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
if ($name !== $before_bind) {
2017-05-04 00:04:17 +03:00
echo "bind: fail\n";
} else {
2017-05-04 00:04:17 +03:00
echo "bind: success\n";
}
var_dump($stmt1->execute());
unset($stmt1);
// Retrieve test data
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
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