icreate install wizard

This commit is contained in:
Manuel Raynaud
2013-09-17 12:17:48 +02:00
parent eeb9a0f9eb
commit edd84fb622
11 changed files with 9962 additions and 4 deletions

View File

@@ -62,6 +62,11 @@ class CheckDatabaseConnection extends BaseInstall
/** @var int Database port information */
protected $port = null;
/**
* @var \PDO instance
*/
protected $connection = null;
/**
* Constructor
*
@@ -90,11 +95,28 @@ class CheckDatabaseConnection extends BaseInstall
*/
public function exec()
{
$link = mysql_connect($this->host . ':' . $this->port, $this->user, $this->password);
if (!$link) {
throw new InstallException('Can\'t connect to the given credentials');
$dsn = "mysql:host=%s";
try {
$this->connection = new \PDO(
sprintf($dsn, $this->host),
$this->user,
$this->password
);
} catch (\PDOException $e) {
$this->validationMessages = 'Wrong connection information';
$this->isValid = false;
}
mysql_close($link);
return $this->isValid;
}
public function getConnection()
{
return $this->connection;
}
}