You are here

public static function DatabaseUtils::BindExpressions in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/utils.inc \DatabaseUtils::BindExpressions()

Summary of BindExpressions

Parameters

PDOStatement $stmt:

array $values:

array $remove_from:

2 calls to DatabaseUtils::BindExpressions()
MergeQuery_sqlsrv::execute in sqlsrv/query.inc
Runs the query against the database.
UpdateQuery_sqlsrv::execute in sqlsrv/query.inc
Executes the UPDATE query.

File

sqlsrv/utils.inc, line 21

Class

DatabaseUtils

Code

public static function BindExpressions(\PDOStatement $stmt, array &$values, array &$remove_from) {
  foreach ($values as $key => $value) {
    unset($remove_from[$key]);
    if (empty($value['arguments'])) {
      continue;
    }
    if (is_array($value['arguments'])) {
      foreach ($value['arguments'] as $placeholder => $argument) {

        // We assume that an expression will never happen on a BLOB field,
        // which is a fairly safe assumption to make since in most cases
        // it would be an invalid query anyway.
        $stmt
          ->bindParam($placeholder, $value['arguments'][$placeholder]);
      }
    }
    else {
      $stmt
        ->bindParam($key, $value['arguments'], PDO::PARAM_STR);
    }
  }
}