1 | <?php |
||
21 | * @package mssql |
||
22 | */ |
||
23 | class MSSQLAzureDatabase extends MSSQLDatabase |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * List of parameters used to create new Azure connections between databases |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $parameters = array(); |
||
32 | |||
33 | public function fullTextEnabled() |
||
37 | |||
38 | public function __construct($parameters) |
||
42 | |||
43 | /** |
||
44 | * Connect to a SQL Azure database with the given parameters. |
||
45 | * @param array $parameters Connection parameters set by environment |
||
46 | * - server: The server, eg, localhost |
||
47 | * - username: The username to log on with |
||
48 | * - password: The password to log on with |
||
49 | * - database: The database to connect to |
||
50 | * - windowsauthentication: Not supported for Azure |
||
51 | */ |
||
52 | public function connect($parameters) |
||
57 | |||
58 | /** |
||
59 | * Connect to a database using the provided parameters |
||
60 | * |
||
61 | * @param string $database |
||
62 | */ |
||
63 | protected function connectDatabase($database) |
||
82 | |||
83 | /** |
||
84 | * Switches to the given database. |
||
85 | * |
||
86 | * IMPORTANT: SQL Azure doesn't support "USE", so we need |
||
87 | * to reinitialize the database connection with the requested |
||
88 | * database name. |
||
89 | * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee336288.aspx |
||
90 | * |
||
91 | * @param string $name The database name to switch to |
||
92 | * @param bool $create |
||
93 | * @param bool|int $errorLevel |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function selectDatabase($name, $create = false, $errorLevel = E_USER_ERROR) |
||
97 | { |
||
98 | $this->fullTextEnabled = null; |
||
99 | if (!$this->schemaManager->databaseExists($name)) { |
||
100 | // Check DB creation permisson |
||
101 | if (!$create) { |
||
102 | if ($errorLevel !== false) { |
||
103 | user_error("Attempted to connect to non-existing database \"$name\"", $errorLevel); |
||
104 | } |
||
105 | // Unselect database |
||
106 | $this->connector->unloadDatabase(); |
||
107 | return false; |
||
108 | } |
||
109 | $this->schemaManager->createDatabase($name); |
||
110 | } |
||
111 | $this->connectDatabase($name); |
||
112 | return true; |
||
115 |