Sql6.php

  1. 8.0.x lib/Drush/Sql/Sql6.php
  2. 7.x lib/Drush/Sql/Sql6.php

Namespace

Drush\Sql

Classes

Namesort descending Description
Sql6

File

lib/Drush/Sql/Sql6.php
View source
  1. <?php
  2. namespace Drush\Sql;
  3. use Drush\Log\LogLevel;
  4. class Sql6 extends SqlVersion {
  5. public function get_db_spec() {
  6. $db_spec = NULL;
  7. if ($url = isset($GLOBALS['db_url']) ? $GLOBALS['db_url'] : drush_get_option('db-url', NULL)) {
  8. $database = drush_get_option('database', 'default');
  9. $url = is_array($url) ? $url[$database] : $url;
  10. $db_spec = drush_convert_db_from_db_url($url);
  11. $db_spec['db_prefix'] = isset($GLOBALS['db_prefix']) ? $GLOBALS['db_prefix'] : drush_get_option('db-prefix', NULL);
  12. // For uniformity with code designed for Drupal 7/8 db_specs, copy the 'db_prefix' to 'prefix'.
  13. $db_spec['prefix'] = $db_spec['db_prefix'];
  14. }
  15. return $db_spec;
  16. }
  17. public function getAll() {
  18. if (isset($GLOBALS['db_url'])) {
  19. return drush_sitealias_convert_db_from_db_url($GLOBALS['db_url']);
  20. }
  21. }
  22. public function valid_credentials($db_spec) {
  23. $type = $db_spec['driver'];
  24. // Check for Drupal support of configured db type.
  25. if (file_exists('./includes/install.'. $type .'.inc')) {
  26. require_once './includes/install.'. $type .'.inc';
  27. $function = $type .'_is_available';
  28. if (!$function()) {
  29. drush_log(dt('!type extension for PHP is not installed. Check your php.ini to see how you can enable it.', array('!type' => $type)), LogLevel::BOOTSTRAP);
  30. return FALSE;
  31. }
  32. }
  33. else {
  34. drush_log(dt('!type database type is unsupported.', array('!type' => $type)), LogLevel::BOOTSTRAP);
  35. return FALSE;
  36. }
  37. return TRUE;
  38. }
  39. }