summaryrefslogtreecommitdiffstats
path: root/db/db.drush.inc
diff options
context:
space:
mode:
Diffstat (limited to 'db/db.drush.inc')
-rw-r--r--db/db.drush.inc42
1 files changed, 21 insertions, 21 deletions
diff --git a/db/db.drush.inc b/db/db.drush.inc
index 0bff9d4..8ae961c 100644
--- a/db/db.drush.inc
+++ b/db/db.drush.inc
@@ -1,5 +1,5 @@
<?php
-// $Id$
+
/**
* @file
* Mysql provisioning module.
@@ -76,14 +76,15 @@ class provisionService_db extends provisionService {
else {
drush_set_error('PROVISION_GRANT_DB_USER_FAILED');
}
- } else {
+ }
+ else {
drush_set_error('PROVISION_CONNECT_DB_FAILED');
}
}
/**
* Find a viable database name, based on the site's uri.
- */
+ */
function suggest_db_name() {
$uri = $this->context->uri;
@@ -101,7 +102,7 @@ class provisionService_db extends provisionService {
}
drush_set_error('PROVISION_CREATE_DB_FAILED', dt("Could not find a free database names after 100 attempts"));
- return false;
+ return FALSE;
}
/**
@@ -112,7 +113,7 @@ class provisionService_db extends provisionService {
$creds = $this->generate_site_credentials();
}
extract($creds);
-
+
if (!$this->can_create_database()) {
drush_set_error('PROVISION_CREATE_DB_FAILED');
drush_log("Database could not be created.", 'error');
@@ -135,9 +136,9 @@ class provisionService_db extends provisionService {
else {
drush_set_error('PROVISION_CREATE_DB_FAILED', dt("Could not create @name database", array("@name" => $db_name)));
}
- return $status;
+ return $status;
}
-
+
/**
* Remove the database and user account for the supplied credentials
*/
@@ -147,18 +148,18 @@ class provisionService_db extends provisionService {
}
extract($creds);
- if ( $this->database_exists($db_name) ) {
+ if ($this->database_exists($db_name)) {
drush_log(dt("Dropping database @dbname", array('@dbname' => $db_name)));
if (!$this->drop_database($db_name)) {
drush_log(dt("Failed to drop database @dbname", array('@dbname' => $db_name)), 'warning');
}
}
-
- if ( $this->database_exists($db_name) ) {
- drush_set_error('PROVISION_DROP_DB_FAILED');
- return FALSE;
+
+ if ($this->database_exists($db_name)) {
+ drush_set_error('PROVISION_DROP_DB_FAILED');
+ return FALSE;
}
-
+
foreach ($this->grant_host_list() as $db_grant_host) {
drush_log(dt("Revoking privileges of %user@%client from %database", array('%user' => $db_user, '%client' => $db_grant_host, '%database' => $db_name)));
if (!$this->revoke($db_name, $db_user, $db_grant_host)) {
@@ -168,7 +169,7 @@ class provisionService_db extends provisionService {
}
- function import_site_database($dump_file = null, $creds = array()) {
+ function import_site_database($dump_file = NULL, $creds = array()) {
if (is_null($dump_file)) {
$dump_file = d()->site_path . '/database.sql';
}
@@ -194,7 +195,7 @@ class provisionService_db extends provisionService {
function generate_site_credentials() {
$creds = array();
- // replace with service type
+ // replace with service type
$db_type = drush_get_option('db_type', function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
// As of Drupal 7 there is no more mysqli type
if (drush_drupal_major_version() >= 7) {
@@ -308,10 +309,10 @@ class provisionService_db_pdo extends provisionService_db {
catch (PDOException $e) {
return drush_set_error('PROVISION_DB_CONNECT_FAIL', $e->getMessage());
}
- }
+ }
function close() {
- $this->conn = null;
+ $this->conn = NULL;
}
function query($query) {
@@ -322,14 +323,14 @@ class provisionService_db_pdo extends provisionService_db {
}
$this->query_callback($args, TRUE);
$query = preg_replace_callback(PROVISION_QUERY_REGEXP, array($this, 'query_callback'), $query);
-
+
try {
$result = $this->conn->query($query);
}
catch (PDOException $e) {
drush_log($e->getMessage(), 'warning');
return FALSE;
- }
+ }
return $result;
@@ -356,7 +357,7 @@ class provisionService_db_pdo extends provisionService_db {
}
}
-
+
function database_exists($name) {
$dsn = $this->dsn . ';dbname=' . $name;
try {
@@ -371,4 +372,3 @@ class provisionService_db_pdo extends provisionService_db {
}
}
}
-