You are here

public function Schema::functionExists in Drupal driver for SQL Server and SQL Azure 3.0.x

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

Find if a table function exists.

Parameters

string $function: Name of the function.

Return value

bool True if the function exists, false otherwise.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php, line 1148

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function functionExists($function) {

  // FN = Scalar Function
  // IF = Inline Table Function
  // TF = Table Function
  // FS | AF = Assembly (CLR) Scalar Function
  // FT | AT = Assembly (CLR) Table Valued Function.
  return $this->connection
    ->queryDirect("SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('" . $function . "') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT', N'AF')")
    ->fetchField() !== FALSE;
}