You are here

private function Schema::defaultValueExpression in Drupal driver for SQL Server and SQL Azure 8

Same name and namespace in other branches
  1. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::defaultValueExpression()

Get the SQL expression for a default value.

Parameters

mixed $table:

mixed $field:

mixed $default:

3 calls to Schema::defaultValueExpression()
Schema::addField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::addField().
Schema::changeField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::changeField().
Schema::createFieldSql in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Create an SQL string for a field to be used in table creation or alteration.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php, line 730
Definition of Drupal\Driver\Database\sqlsrv\Schema

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

private function defaultValueExpression($sqlsr_type, $default) {

  // The actual expression depends on the target data type as it might require conversions.
  $result = is_string($default) ? "'" . addslashes($default) . "'" : $default;
  if (DatabaseUtils::GetMSSQLType($sqlsr_type) == 'varbinary') {
    $default = addslashes($default);
    $result = "CONVERT({$sqlsr_type}, '{$default}')";
  }
  return $result;
}