You are here

protected function Statement::fixColumnBindings in Drupal driver for SQL Server and SQL Azure 8.2

Make sure that SQL Server types are properly binded to PHP types.

Only need when using CLIENT BASED PREFETCH.

1 call to Statement::fixColumnBindings()
Statement::execute in drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php
Execute a statement.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Statement.php, line 190

Class

Statement
Turbocharged Statement class to work with MSSQL server.

Namespace

Drupal\Driver\Database\sqlsrv\PDO

Code

protected function fixColumnBindings() {
  $null = array();
  $meta = $this
    ->getColumnMetaCustom();
  $this->columnNames = array_column($meta, 'name');
  foreach ($meta as $i => $meta) {
    $type = $meta['sqlsrv_type'];
    switch ($type) {
      case 'varbinary':
        $null[$i] = null;
        $this
          ->bindColumn($i + 1, $null[$i], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
        break;
      case 'int':
      case 'bit':
      case 'smallint':
      case 'tinyint':
      case 'bigint':
        $null[$i] = null;
        $this
          ->bindColumn($i + 1, $null[$i], PDO::PARAM_INT);
        break;
      case 'nvarchar':
      case 'varchar':
        $null[$i] = null;
        $this
          ->bindColumn($i + 1, $null[$i], PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_UTF8);
        break;
    }
  }
}