sql.drush.inc

  1. 8.0.x commands/sql/sql.drush.inc
  2. 6.x commands/sql/sql.drush.inc
  3. 7.x commands/sql/sql.drush.inc
  4. 3.x commands/sql/sql.drush.inc
  5. 4.x commands/sql/sql.drush.inc
  6. 5.x commands/sql/sql.drush.inc
  7. master commands/sql/sql.drush.inc

Drush sql commands

Functions

Namesort descending Description
drush_sql_build_dump_command
drush_sql_cli
drush_sql_conf Command callback. Displays the Drupal site's database connection string.
drush_sql_connect
drush_sql_dump Build a mysqldump statement.
drush_sql_dump_execute Command callback. Outputs the entire Drupal database in SQL format using mysqldump.
drush_sql_dump_file Determine where to store an sql dump file. This function is called by sql-sync if the caller did not explicitly specify a dump file to use.
drush_sql_get_table_selection
drush_sql_query Command callback. Executes the given SQL query on the Drupal database.
sql_drush_command Implementation of hook_drush_command().
sql_drush_help Implementation of hook_drush_help().
_drush_sql_connect Command callback. Emits a connect string for mysql or pgsql.
_drush_sql_get_credentials Build a fragment containing credentials and mysql-connection parameters.
_drush_sql_get_db_spec Get a database specification for the active DB connection. Honors the 'database' and 'target command' line options.
_drush_sql_get_invalid_url_msg
_drush_sql_get_scheme
_drush_sql_get_spec_from_options
_drush_sql_get_table_list Consult the specified options and return the list of tables specified.
_drush_sql_query

File

commands/sql/sql.drush.inc
View source
  1. <?php
  2. /**
  3. * @file Drush sql commands
  4. */
  5. /**
  6. * Implementation of hook_drush_help().
  7. */
  8. function sql_drush_help($section) {
  9. switch ($section) {
  10. case 'drush:sql-conf':
  11. return dt('Show database connection details.');
  12. case 'drush:sql-connect':
  13. return dt('A string which connects to the current database.');
  14. case 'drush:sql-cli':
  15. return dt('Quickly enter the mysql command line.');
  16. case 'drush:sql-dump':
  17. return dt('Prints the whole database to STDOUT or save to a file.');
  18. case 'drush:sql-query':
  19. return dt("Usage: drush [options] sql-query <query>...\n<query> is a SQL statement, which can alternatively be passed via STDIN. Any additional arguments are passed to the mysql command directly.");
  20. case 'drush:sql-sync':
  21. return dt("Usage: drush [options] sql-sync <source_alias> <target_alias>.\n <source_alias> and <target_alias> are site-aliases, or names of directories under \'sites\'. These determine from where and to where you want your database copied.");
  22. }
  23. }
  24. /**
  25. * Implementation of hook_drush_command().
  26. */
  27. function sql_drush_command() {
  28. $options['--database'] = 'The DB connection key if using multiple connections in settings.php.';
  29. if (drush_drupal_major_version() >= 7) {
  30. $options['--target'] = 'The name of a target within the specified database.';
  31. }
  32. $items['sql-conf'] = array(
  33. 'description' => 'Print database connection details using print_r().',
  34. 'arguments' => array(
  35. 'all' => 'Show all database connections, instead of just one.',
  36. ),
  37. 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
  38. 'options' => $options,
  39. );
  40. $items['sql-connect'] = array(
  41. 'description' => 'A string for connecting to the DB.',
  42. 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
  43. 'options' => $options,
  44. 'examples' => array(
  45. '`drush sql connect` < example.sql' => 'Import sql statements from a file into the current database.',
  46. ),
  47. );
  48. $items['sql-dump'] = array(
  49. 'callback' => 'drush_sql_dump_execute',
  50. 'description' => 'Exports the Drupal DB as SQL using mysqldump.',
  51. 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
  52. 'examples' => array(
  53. 'drush sql-dump --result-file=../18.sql' => 'Save SQL dump to the directory above Drupal root.',
  54. 'drush sql-dump --skip-tables-key=common' => 'Skip standard tables. @see example.drushrc.com',
  55. ),
  56. 'options' => array(
  57. '--result-file' => 'Save to a file. The file should be relative to Drupal root. Recommended.',
  58. '--skip-tables-key' => 'A key in the $skip_tables array. @see example.drushrc.php. Optional.',
  59. '--structure-tables-key' => 'A key in the $structure_tables array. @see example.drushrc.php. Optional.',
  60. '--tables-key' => 'A key in the $tables array. Optional.',
  61. '--tables-list' => 'A comma-separated list of tables to transfer. Optional.',
  62. '--ordered-dump' => 'Use this option to output ordered INSERT statements in the sql-dump.Useful when backups are managed in a Version Control System. Optional.',
  63. '--create-db' => 'Wipe existing tables.',
  64. '--data-only' => 'Omit CREATE TABLE statements. Postgres only.',
  65. '--ordered-dump' => 'Order by primary key and add line breaks for efficient diff in revision control. Also, faster rsync. Slows down the dump. Mysql only.',
  66. ) + $options,
  67. );
  68. $items['sql-query'] = array(
  69. 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_DATABASE,
  70. 'description' => 'Execute a query against the site database.',
  71. 'examples' => array(
  72. 'drush sql-query "SELECT * FROM {users} WHERE uid=1"' => 'Browse user record. Table prefixes are honored.',
  73. ),
  74. 'arguments' => array(
  75. 'query' => 'A SQL query. Mandatory.',
  76. ),
  77. 'options' => array(
  78. '--extra' => 'Add custom options to the mysql command.',
  79. ) + $options,
  80. 'aliases' => array('sqlq'),
  81. );
  82. $items['sql-sync'] = array(
  83. 'description' => 'Copy source database to target database using rsync.',
  84. 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
  85. 'examples' => array(
  86. 'drush sql-sync @dev @prod' => 'Copy the DB defined in sites/dev to the DB in sites/prod.',
  87. ),
  88. 'arguments' => array(
  89. 'from' => 'Name of subdirectory within /sites or a site-alias.',
  90. 'to' => 'Name of subdirectory within /sites or a site-alias.',
  91. ),
  92. 'options' => array(
  93. '--skip-tables-key' => 'A key in the $skip_tables array. @see example.drushrc.php. Optional.',
  94. '--structure-tables-key' => 'A key in the $structure_tables array. @see example.drushrc.php. Optional.',
  95. '--tables-key' => 'A key in the $tables array. Optional.',
  96. '--tables-list' => 'A comma-separated list of tables to transfer. Optional.',
  97. '--cache' => 'Skip dump if result file exists and is less than "cache" hours old. Optional; default is 24 hours.',
  98. '--no-cache' => 'Do not cache the sql-dump file.',
  99. '--no-dump' => 'Do not dump the sql database; always use an existing dump file.',
  100. '--source-db-url' => 'Database specification for source system to dump from.',
  101. '--source-remote-port' => 'Override sql database port number in source-db-url. Optional.',
  102. '--source-remote-host' => 'Remote machine to run sql-dump file on. Optional; default is local machine.',
  103. '--source-dump' => 'Path to dump file. Optional; default is to create a temporary file.',
  104. '--target-db-url' => '',
  105. '--target-remote-port' => '',
  106. '--target-remote-host' => '',
  107. '--target-dump' => '',
  108. '--temp' => 'Use a temporary file to hold dump files. Implies --no-cache.',
  109. '--dump-dir' => 'Directory to store sql dump files in when --source-dump or --target-dump are not used. Takes precedence over --temp.',
  110. '--create-db' => 'Create a new database before importing the database dump on the target machine.',
  111. '--db-su' => 'Account to use when creating a new database. Optional.',
  112. '--db-su-pw' => 'Password for the "db-su" account. Optional.',
  113. ),
  114. );
  115. if (drush_drupal_major_version() >= 7) {
  116. $items['sql-sync']['options'] += array(
  117. '--source-target' => 'The name of a target within the SOURCE database.',
  118. '--destination-target' => 'The name of a target within the specified DESTINATION database.',
  119. );
  120. }
  121. $items['sql-cli'] = array(
  122. 'description' => "Open a SQL command-line interface using Drupal's credentials.",
  123. 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION,
  124. 'options' => $options,
  125. 'aliases' => array('sqlc'),
  126. );
  127. return $items;
  128. }
  129. /**
  130. * Command callback. Displays the Drupal site's database connection string.
  131. */
  132. function drush_sql_conf() {
  133. if (drush_get_option('db-url', FALSE)) {
  134. $db_spec['db-url'] = $GLOBALS['db_url'];
  135. }
  136. elseif (drush_get_option('all', FALSE)) {
  137. $db_spec = $GLOBALS['databases'];
  138. if (!isset($db_spec)) {
  139. $db_spec = array('default' => array('default' => _drush_sql_get_db_spec()));
  140. }
  141. }
  142. if (!isset($db_spec)) {
  143. $db_spec = _drush_sql_get_db_spec();
  144. }
  145. drush_backend_set_result($db_spec);
  146. if (!drush_get_option('show-passwords', FALSE)) {
  147. drush_unset_recursive($db_spec, 'password');
  148. }
  149. drush_print_r($db_spec);
  150. }
  151. /**
  152. * Command callback. Emits a connect string for mysql or pgsql.
  153. */
  154. function _drush_sql_connect($db_spec = NULL) {
  155. switch (_drush_sql_get_scheme($db_spec)) {
  156. case 'mysql':
  157. $command = 'mysql ' . (drush_get_context('DRUSH_DEBUG') ? ' -v' : '');
  158. $command .= _drush_sql_get_credentials($db_spec);
  159. break;
  160. case 'pgsql':
  161. $command = 'psql';
  162. $command .= _drush_sql_get_credentials($db_spec);
  163. break;
  164. }
  165. return $command;
  166. }
  167. function drush_sql_connect() {
  168. drush_print(_drush_sql_connect());
  169. }
  170. /**
  171. * Command callback. Outputs the entire Drupal database in SQL format using mysqldump.
  172. */
  173. function drush_sql_dump_execute() {
  174. $exec = drush_sql_dump();
  175. // Avoid the php memory of the $output array in drush_shell_exec().
  176. $return = drush_op('system', $exec);
  177. return $return;
  178. }
  179. function drush_sql_get_table_selection() {
  180. // Skip large core tables if instructed. Also used by 'sql-sync' command.
  181. $skip_tables = _drush_sql_get_table_list('skip-tables');
  182. // Skip any structure-tables as well.
  183. $structure_tables = _drush_sql_get_table_list('structure-tables');
  184. // Dump only the specified tables. Takes precedence over skip-tables and structure-tables.
  185. $tables = _drush_sql_get_table_list('tables');
  186. return array('skip' => $skip_tables, 'structure' => $structure_tables, 'tables' => $tables);
  187. }
  188. /**
  189. * Build a mysqldump statement.
  190. *
  191. * @param db_spec
  192. * For D5/D6, a $db_url. For D7, a target in the default DB connection.
  193. * @return string
  194. * A mysqldump statement that is ready for executing.
  195. */
  196. function drush_sql_dump($db_spec = NULL) {
  197. return drush_sql_build_dump_command(drush_sql_get_table_selection(), $db_spec);
  198. }
  199. function drush_sql_build_dump_command($tabel_selection, $db_spec = NULL) {
  200. $skip_tables = $tabel_selection['skip'];
  201. $structure_tables = $tabel_selection['structure'];
  202. $tables = $tabel_selection['tables'];
  203. $ignores = array();
  204. $skip_tables += $structure_tables;
  205. $data_only = drush_get_option('data-only');
  206. // The ordered-dump option is only supported by MySQL for now.
  207. // @todo add documention once a hook for drush_get_option_help() is available.
  208. // @see drush_get_option_help() in drush.inc
  209. $ordered_dump = drush_get_option('ordered-dump');
  210. if (is_null($db_spec)) {
  211. $db_spec = _drush_sql_get_db_spec();
  212. }
  213. $database = $db_spec['database'];
  214. switch (_drush_sql_get_scheme($db_spec)) {
  215. case 'mysql':
  216. $exec = 'mysqldump' . (drush_get_context('DRUSH_VERBOSE') ? ' -v' : '');
  217. if ($file = drush_get_option('result-file')) {
  218. $exec .= ' --result-file '. $file;
  219. }
  220. $extra = ' --single-transaction --opt -Q' . _drush_sql_get_credentials($db_spec);
  221. if (isset($data_only)) {
  222. $extra .= ' --no-create-info';
  223. }
  224. if (isset($ordered_dump)) {
  225. $extra .= ' --skip-extended-insert --order-by-primary';
  226. }
  227. $exec .= $extra;
  228. if (!empty($tables)) {
  229. $exec .= ' ' . implode(' ', $tables);
  230. }
  231. else {
  232. // Append the ignore-table options.
  233. foreach ($skip_tables as $table) {
  234. $ignores[] = "--ignore-table=$database.$table";
  235. }
  236. $exec .= ' '. implode(' ', $ignores);
  237. // Run mysqldump again and append output if we need some structure only tables.
  238. if (!empty($structure_tables)) {
  239. $exec .= "; mysqldump --no-data $extra " . implode(' ', $structure_tables);
  240. if ($file) {
  241. $exec .= " >> $file";
  242. }
  243. }
  244. }
  245. break;
  246. case 'pgsql':
  247. $create_db = drush_get_option('create-db');
  248. $exec = 'pg_dump ' . (drush_get_context('DRUSH_VERBOSE') ? ' -v' : '');
  249. if ($file = drush_get_option('result-file')) {
  250. $exec .= ' --file '. $file;
  251. }
  252. // Unlike psql, pg_dump does not take a '-d' flag before the database name.
  253. // We'll put the database name in 'by hand' and then clear the name from
  254. // the record to prevent _drush_sql_get_credentials from inserting a -d term
  255. // that pg_dump does not understand.
  256. $extra = ' ' . $db_spec['database'];
  257. $db_spec['database'] = null;
  258. $extra .= _drush_sql_get_credentials($db_spec);
  259. if (isset($data_only)) {
  260. $extra .= ' --data-only';
  261. }
  262. $exec .= $extra;
  263. $exec .= (!isset($create_db) && !isset($data_only) ? ' --clean' : '');
  264. if (!empty($tables)) {
  265. foreach ($tables as $table) {
  266. $exec .= " --table=$table";
  267. }
  268. }
  269. else {
  270. foreach ($skip_tables as $table) {
  271. $ignores[] = "--exclude-table=$table";
  272. }
  273. $exec .= ' '. implode(' ', $ignores);
  274. // Run pg_dump again and append output if we need some structure only tables.
  275. if (!empty($structure_tables)) {
  276. $schemaonlies = array();
  277. foreach ($structure_tables as $table) {
  278. $schemaonlies[] = "--table=$table";
  279. }
  280. $exec .= "; pg_dump --schema-only " . implode(' ', $schemaonlies) . $extra;
  281. if ($file) {
  282. $exec .= " >> $file";
  283. }
  284. }
  285. }
  286. break;
  287. }
  288. return $exec;
  289. }
  290. /**
  291. * Consult the specified options and return the list of tables
  292. * specified.
  293. *
  294. * @param option_name
  295. * The option name to check: skip-tables, structure-tables
  296. * or tables. This funciton will check both *-key and *-list,
  297. * and, in the case of sql-sync, will also check target-*
  298. * and source-*, to see if an alias set one of these options.
  299. * @returns array
  300. * Returns an array of tables based on the first option
  301. * found, or an empty array if there were no matches.
  302. */
  303. function _drush_sql_get_table_list($option_name) {
  304. foreach(array('' => 'options', 'target-,,source-' => NULL) as $prefix_list => $context) {
  305. foreach(explode(',',$prefix_list) as $prefix) {
  306. $key_list = drush_get_option($prefix . $option_name . '-key', NULL, $context);
  307. foreach(explode(',', $key_list) as $key) {
  308. $all_tables = drush_get_option($option_name, array());
  309. if (array_key_exists($key, $all_tables)) {
  310. return $all_tables[$key];
  311. }
  312. if ($option_name != 'tables') {
  313. $all_tables = drush_get_option('tables', array());
  314. if (array_key_exists($key, $all_tables)) {
  315. return $all_tables[$key];
  316. }
  317. }
  318. }
  319. $table_list = drush_get_option($prefix . $option_name . '-list', NULL, $context);
  320. if (isset($table_list)) {
  321. return empty($table_list) ? array() : explode(',', $table_list);
  322. }
  323. }
  324. }
  325. return array();
  326. }
  327. /**
  328. * Command callback. Executes the given SQL query on the Drupal database.
  329. */
  330. function drush_sql_query($query) {
  331. return _drush_sql_query($query);
  332. }
  333. function _drush_sql_query($query, $db_spec = NULL) {
  334. $scheme = _drush_sql_get_scheme($db_spec);
  335. // Inject table prefixes as needed.
  336. if (drush_drupal_major_version() >= 7) {
  337. $query = Database::getConnection()->prefixTables($query);
  338. }
  339. else {
  340. $query = db_prefix_tables($query);
  341. }
  342. // Convert mysql 'show tables;' query into something pgsql understands
  343. if (($scheme == 'pgsql') && ($query == 'show tables;')) {
  344. $query = "select tablename from pg_tables where schemaname='public';";
  345. }
  346. // Save $query to a tmp file. We will redirect it in.
  347. if ($file = drush_save_data_to_temp_file($query)) {
  348. switch ($scheme) {
  349. case 'mysql':
  350. $exec = 'mysql' . (drush_get_context('DRUSH_VERBOSE') ? ' -v' : '');
  351. $exec .= _drush_sql_get_credentials($db_spec);
  352. $exec .= ' ' . drush_get_option('extra');
  353. $exec .= " < $file";
  354. break;
  355. case 'pgsql':
  356. $exec = 'psql';
  357. $exec .= _drush_sql_get_credentials($db_spec);
  358. $exec .= (drush_get_context('DRUSH_VERBOSE') ? '' : ' -q');
  359. $exec .= ' ' . (drush_get_option('extra') ? drush_get_option('extra') : "--no-align --field-separator=$'\t' --pset footer=off");
  360. $exec .= " --file $file";
  361. break;
  362. }
  363. $return = drush_op('system', $exec) !== FALSE;
  364. return $return;
  365. }
  366. }
  367. function drush_sql_cli() {
  368. switch (_drush_sql_get_scheme()) {
  369. case 'mysql':
  370. $command = 'mysql ' . (drush_get_context('DRUSH_VERBOSE') ? ' -v' : '');
  371. $command .= _drush_sql_get_credentials();
  372. break;
  373. case 'pgsql':
  374. $command = ' psql';
  375. $command .= _drush_sql_get_credentials();
  376. break;
  377. }
  378. proc_close(proc_open($command, array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes));
  379. }
  380. //////////////////////////////////////////////////////////////////////////////
  381. // SQL SERVICE HELPERS
  382. /**
  383. * Get a database specification for the active DB connection. Honors the
  384. * 'database' and 'target command' line options.
  385. *
  386. * @return
  387. * An info array describing a database target.
  388. */
  389. function _drush_sql_get_db_spec() {
  390. $database = drush_get_option('database', 'default');
  391. $target = drush_get_option('target', 'default');
  392. switch (drush_drupal_major_version()) {
  393. case 5:
  394. case 6:
  395. $url = $GLOBALS['db_url'];
  396. // TODO: array version not working?
  397. $url = is_array($url) ? $url[$database] : $url;
  398. return drush_convert_db_from_db_url($url);
  399. default:
  400. // We don't use DB API here `sql-sync` would have to messily addConnection.
  401. if (!isset($GLOBALS['databases']) || !array_key_exists($database, $GLOBALS['databases']) || !array_key_exists($target, $GLOBALS['databases'][$database])) {
  402. return NULL;
  403. }
  404. return $GLOBALS['databases'][$database][$target];
  405. }
  406. }
  407. function _drush_sql_get_spec_from_options($prefix, $default_to_self = TRUE) {
  408. $db_spec = NULL;
  409. $databases = drush_get_option($prefix . 'databases');
  410. if (isset($databases) && !empty($databases)) {
  411. $database = drush_get_option($prefix . 'database', 'default');
  412. $target = drush_get_option($prefix . 'target', 'default');
  413. if (array_key_exists($database, $databases) && array_key_exists($target, $databases[$database])) {
  414. $db_spec = $databases[$database][$target];
  415. }
  416. }
  417. else {
  418. $db_url = drush_get_option($prefix . 'db-url');
  419. if (isset($db_url)) {
  420. $db_spec = drush_convert_db_from_db_url($db_url);
  421. }
  422. elseif ($default_to_self) {
  423. $db_spec = _drush_sql_get_db_spec();
  424. }
  425. }
  426. if (isset($db_spec)) {
  427. $remote_host = drush_get_option($prefix . 'remote-host');
  428. if (!drush_is_local_host($remote_host)) {
  429. $db_spec['remote-host'] = $remote_host;
  430. $db_spec['port'] = drush_get_option($prefix . 'remote-port', $db_spec['port']);
  431. }
  432. }
  433. return $db_spec;
  434. }
  435. /**
  436. * Determine where to store an sql dump file. This
  437. * function is called by sql-sync if the caller did
  438. * not explicitly specify a dump file to use.
  439. *
  440. * @param db_spec
  441. * Information about the database being dumped; used
  442. * to generate the filename.
  443. * @return string
  444. * The path to the dump file
  445. */
  446. function drush_sql_dump_file(&$db_spec) {
  447. // Make a base filename pattern to use to name the dump file
  448. $filename_pattern = $db_spec['database'];
  449. if (isset($db_spec['remote-host'])) {
  450. $filename_pattern = $db_spec['remote-host'] . '_' . $filename_pattern;
  451. }
  452. // If the user has set the --dump-dir option, then
  453. // store persistant sql dump files there.
  454. $dump_dir = drush_get_option(array('source-dump-dir', 'dump-dir'));
  455. if (isset($dump_dir)) {
  456. $dump_file = $dump_dir . '/' . $filename_pattern . '.sql';
  457. }
  458. // If the --dump-dir option is not set, then store
  459. // the sql dump in a temporary file.
  460. else {
  461. $dump_file = drush_tempnam($filename_pattern . '.sql.');
  462. $db_spec['dump-is-temp'] = TRUE;
  463. }
  464. return $dump_file;
  465. }
  466. function _drush_sql_get_scheme($db_spec = NULL) {
  467. if (is_null($db_spec)) {
  468. $db_spec = _drush_sql_get_db_spec();
  469. }
  470. return $db_spec['driver'];
  471. }
  472. /**
  473. * Build a fragment containing credentials and mysql-connection parameters.
  474. *
  475. * @param $db_spec
  476. * @return string
  477. */
  478. function _drush_sql_get_credentials($db_spec = NULL) {
  479. if (is_null($db_spec)) {
  480. $db_spec = _drush_sql_get_db_spec();
  481. }
  482. switch (_drush_sql_get_scheme($db_spec)) {
  483. case 'mysql':
  484. $cred = ' -h' . $db_spec['host'] .
  485. (empty($db_spec['port']) ? '' : ' -P' . $db_spec['port']) .
  486. ' -u' . $db_spec['username'] .
  487. (empty($db_spec['password']) ? '' : ' -p' . $db_spec['password']) . ' ' . $db_spec['database'];
  488. break;
  489. case 'pgsql':
  490. $cred = (isset($db_spec['database']) ? ' -d ' . (empty($db_spec['database']) ? 'template1' : $db_spec['database']) : '') .
  491. (empty($db_spec['host']) ? ' -h localhost ' : ' -h ' . $db_spec['host']) .
  492. (empty($db_spec['port']) ? ' -p 5432 ' : ' -p ' . $db_spec['port']);
  493. // Adding '-U' will cause Postgres to prompt for a password, so disable this for now.
  494. // Use "sudo -u postgres drush sql ..." to access the database without a password,
  495. // presuming that "postgres" is the database superuser and you have
  496. // "local all all ident sameuser" in your Postgres pg_hba.conf file.
  497. // See: http://drupal.org/node/438828
  498. $cred .= ' -U ' . $db_spec['username'] . ' ';
  499. break;
  500. }
  501. return escapeshellcmd($cred);
  502. }
  503. function _drush_sql_get_invalid_url_msg($db_spec = NULL) {
  504. if (is_null($db_spec)) {
  505. $db_spec = _drush_sql_get_db_spec();
  506. }
  507. switch (drush_drupal_major_version()) {
  508. case 5:
  509. case 6:
  510. return dt('Unable to parse DB connection string');
  511. default:
  512. return dt('Unable to parse DB connection array');
  513. }
  514. }