commit
c6157b0f79
|
@ -738,6 +738,10 @@ int pdo_sqlsrv_stmt_get_col_data(pdo_stmt_t *stmt, int colno,
|
||||||
|
|
||||||
pdo_bound_param_data* bind_data = NULL;
|
pdo_bound_param_data* bind_data = NULL;
|
||||||
bind_data = reinterpret_cast<pdo_bound_param_data*>(zend_hash_index_find_ptr(stmt->bound_columns, colno));
|
bind_data = reinterpret_cast<pdo_bound_param_data*>(zend_hash_index_find_ptr(stmt->bound_columns, colno));
|
||||||
|
if (bind_data == NULL) {
|
||||||
|
// can't find by index then try searching by name
|
||||||
|
bind_data = reinterpret_cast<pdo_bound_param_data*>(zend_hash_find_ptr(stmt->bound_columns, stmt->columns[colno].name));
|
||||||
|
}
|
||||||
|
|
||||||
if( bind_data != NULL && !Z_ISUNDEF(bind_data->driver_params) ) {
|
if( bind_data != NULL && !Z_ISUNDEF(bind_data->driver_params) ) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
--TEST--
|
||||||
|
GitHub Issue #35 binary encoding error when binding by name
|
||||||
|
--SKIPIF--
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
require_once("autonomous_setup.php");
|
||||||
|
|
||||||
|
// Connect
|
||||||
|
$dbName = "tempdb";
|
||||||
|
$conn = new PDO( "sqlsrv:server=$serverName ; database=$dbName", $username, $password);
|
||||||
|
|
||||||
|
// Create a temp table
|
||||||
|
$number = rand(0,1000);
|
||||||
|
$tableName = "testTableIssue35" . "_" . $number;
|
||||||
|
$sql = "CREATE TABLE $tableName (Value varbinary(max))";
|
||||||
|
$stmt = $conn->query($sql);
|
||||||
|
|
||||||
|
// Insert data using bind parameters
|
||||||
|
$sql = "INSERT INTO $tableName VALUES (?)";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$message = "This is to test github issue 35.";
|
||||||
|
$value = base64_encode($message);
|
||||||
|
|
||||||
|
$stmt->setAttribute(constant('PDO::SQLSRV_ATTR_ENCODING'), PDO::SQLSRV_ENCODING_BINARY);
|
||||||
|
$stmt->bindParam(1, $value, PDO::PARAM_LOB);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
|
||||||
|
// fetch it back
|
||||||
|
$stmt = $conn->prepare("SELECT Value FROM $tableName");
|
||||||
|
$stmt->bindColumn('Value', $val1, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->fetch(PDO::FETCH_BOUND);
|
||||||
|
var_dump($val1 === $value);
|
||||||
|
|
||||||
|
$stmt = $conn->query("DROP TABLE $tableName");
|
||||||
|
|
||||||
|
// Close connection
|
||||||
|
$stmt = null;
|
||||||
|
$conn = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
test();
|
||||||
|
print "Done";
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
Done
|
||||||
|
|
Loading…
Reference in a new issue