You are here

public static function Utils::GetExtendedProperty in Drupal driver for SQL Server and SQL Azure 8.2

Parameters

null|string $property_name:

null|string $level0_object_type:

null|string $level0_object_name:

null|string $level1_object_type:

null|string $level1_object_name:

null|string $level2_object_type:

null|string $level2_object_name:

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Utils.php, line 176

Class

Utils

Namespace

Drupal\Driver\Database\sqlsrv

Code

public static function GetExtendedProperty($property_name = null, $level0_object_type = null, $level0_object_name = null, $level1_object_type = null, $level1_object_name = null, $level2_object_type = null, $level2_object_name = null) {
  $level_o = array(
    "ASSEMBLY",
    "CONTRACT",
    "EVENT NOTIFICATION",
    "FILEGROUP",
    "MESSAGE TYPE",
    "PARTITION FUNCTION",
    "PARTITION SCHEME",
    "REMOTE SERVICE BINDING",
    "ROUTE",
    "SCHEMA",
    "SERVICE",
    "TRIGGER",
    "TYPE",
    "USER",
    "NULL",
  );
  if (!empty($level0_object_type) && !in_array(strtoupper($level0_object_type), $level_o)) {
    throw new \Exception("Invalid Level0 Object Type.");
  }
  $level_1 = array(
    "AGGREGATE",
    "DEFAULT",
    "FUNCTION",
    "LOGICAL FILE NAME",
    "PROCEDURE",
    "QUEUE",
    "RULE",
    "SYNONYM",
    "TABLE",
    "TYPE",
    "VIEW",
    "XML",
    "SCHEMA COLLECTION",
    "NULL",
  );
  if (!empty($level1_object_type) && !in_array(strtoupper($level1_object_type), $level_1)) {
    throw new \Exception("Invalid Level1 Object Type.");
  }
  $level_2 = array(
    "COLUMN",
    "CONSTRAINT",
    "EVENT NOTIFICATION",
    "INDEX",
    "PARAMETER",
    "TRIGGER",
    "NULL",
  );
  if (!empty($level2_object_type) && !in_array(strtoupper($level2_object_type), $level_2)) {
    throw new \Exception("Invalid Level2 Object Type.");
  }
  $query = <<<EVB
  SELECT
    CONVERT(nvarchar(max), value) AS value,
    CONVERT(nvarchar(max), objtype) AS objtype,
    CONVERT(nvarchar(max), objname) AS objname,
    CONVERT(nvarchar(max), name) AS name
  FROM fn_listextendedproperty(:property_name, :level0_object_type, :level0_object_name,:level1_object_type, :level1_object_name,:level2_object_type, :level2_object_name)
EVB;
  return array(
    'query' => $query,
    'args' => array(
      ':property_name' => $property_name,
      ':level0_object_type' => $level0_object_type,
      ':level0_object_name' => $level0_object_name,
      ':level1_object_type' => $level1_object_type,
      ':level1_object_name' => $level1_object_name,
      ':level2_object_type' => $level2_object_type,
      ':level2_object_name' => $level2_object_name,
    ),
  );
}