public function Statement::BindValues in Drupal driver for SQL Server and SQL Azure 8.2
Binds a set of values to a PDO Statement, taking care of properly managing binary data.
Parameters
PDOStatement $stmt: PDOStatement to bind the values to
array $values: Values to bind. It's an array where the keys are column names and the values what is going to be inserted.
array $blobs: When sending binary data to the PDO driver, we need to keep track of the original references to data
array $ref_prefix: The $ref_holder might be shared between statements, use this prefix to prevent key colision.
mixed $placeholder_prefix: Prefix to use for generating the query placeholders.
mixed $max_placeholder: Placeholder count, if NULL will start with 0.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ PDO/ Statement.php, line 284
Class
- Statement
- Turbocharged Statement class to work with MSSQL server.
Namespace
Drupal\Driver\Database\sqlsrv\PDOCode
public function BindValues(array &$values, array &$blobs, $placeholder_prefix, $columnInformation, &$max_placeholder = null, $blob_suffix = null) {
if (empty($max_placeholder)) {
$max_placeholder = 0;
}
foreach ($values as $field_name => &$field_value) {
$placeholder = $placeholder_prefix . $max_placeholder++;
$blob_key = $placeholder . $blob_suffix;
if (isset($columnInformation['blobs'][$field_name])) {
$blobs[$blob_key] = fopen('php://memory', 'a');
fwrite($blobs[$blob_key], $field_value);
rewind($blobs[$blob_key]);
$this
->bindParam($placeholder, $blobs[$blob_key], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
}
else {
// Even though not a blob, make sure we retain a copy of these values.
$blobs[$blob_key] = $field_value;
$this
->bindParam($placeholder, $blobs[$blob_key], PDO::PARAM_STR);
}
}
}