DatabaseTasks::connect

protected function DatabaseTasks::connect

protected DatabaseTasks::connect()

Check if we can connect to the database.

File

includes/install.inc, line 431
API functions for installing modules and themes.

Class

DatabaseTasks
Database installer structure.

Code

protected function connect() {
  try {
    // This doesn't actually test the connection.
    db_set_active();
    // Now actually do a check.
    Database::getConnection();
    $this->pass('Drupal can CONNECT to the database ok.');
  }
  catch (Exception $e) {
    $this->fail(st('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', array('%error' => $e->getMessage())));
    return FALSE;
  }
  return TRUE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!install.inc/function/DatabaseTasks::connect/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部