You are here

function db_maintenance_get_mysql_options in DB Maintenance 5.2

Same name and namespace in other branches
  1. 6.2 db_maintenance.module \db_maintenance_get_mysql_options()
1 call to db_maintenance_get_mysql_options()
db_maintenance_do_db_backup in ./db_maintenance.module

File

./db_maintenance.module, line 513
Optimizes database tables during cron runs.

Code

function db_maintenance_get_mysql_options() {
  global $db_url;
  $url = parse_url($db_url);
  $url['host'] = urldecode($url['host']);
  $url['path'] = urldecode($url['path']);
  $url['user'] = urldecode($url['user']);
  if (isset($url['pass'])) {
    $url['pass'] = urldecode($url['pass']);
  }
  else {
    $url['pass'] = '';
  }
  if ($url['host']) {
    $options[] = '--host=' . $url['host'];
  }
  if (!empty($url['port'])) {
    $options[] = '--port=' . $url['port'];
  }
  if ($url['pass'] != '') {
    $options[] = '--password=' . $url['pass'];
  }
  if ($url['user']) {
    $options[] = '--user=' . $url['user'];
  }
  $return = implode(' ', $options);
  $return .= ' ' . substr($url['path'], 1);

  // db name is 'path' with '/' pre-pended
  return $return;
}