Skip to content

Commit

Permalink
Friendly error when mPDO error occurs on installation of Opencart.
Browse files Browse the repository at this point in the history
  • Loading branch information
tijme committed Jul 9, 2015
1 parent 64d143b commit 06f28dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions upload/install/controller/step_3.php
Expand Up @@ -271,6 +271,12 @@ private function validate() {
} else {
$mysql->close();
}
} elseif ($this->request->post['db_driver'] == 'mpdo') {
try {
new \DB\mPDO($this->request->post['db_hostname'], $this->request->post['db_username'], $this->request->post['db_password'], $this->request->post['db_database'], $this->request->post['db_port']);
} catch(Exception $e) {
$this->error['warning'] = $e->getMessage();
}
}

if (!$this->request->post['username']) {
Expand Down
2 changes: 1 addition & 1 deletion upload/system/library/db/mpdo.php
Expand Up @@ -8,7 +8,7 @@ public function __construct($hostname, $username, $password, $database, $port =
try {
$this->pdo = new \PDO("mysql:host=" . $hostname . ";port=" . $port . ";dbname=" . $database, $username, $password, array(\PDO::ATTR_PERSISTENT => true));
} catch(\PDOException $e) {
trigger_error('Error: Could not make a database link ( ' . $e->getMessage() . '). Error Code : ' . $e->getCode() . ' <br />');
throw new \Exception('Unknown database \'' . $database . '\'');
exit();
}

Expand Down

0 comments on commit 06f28dc

Please sign in to comment.