array ( 'type' => $this->getType (), 'database' => $this->getDatabase (), 'host' => $this->getHost (), 'user' => $this->getUser (), 'pass' => $this->getPassword (), 'port' => $this->getPort () ), 'table_prefix' => $this->getTablePrefix () ); return $res; } function test () { $this->startErrorControl (); try { $d = new Database ($this->getConnectionSettings ()); $d->connect (); } catch (Exception $e) { $this->setRuntimeError ($e->getMessage ()); } $this->finishErrorControl (); if ($this->hasRuntimeError ()) { echo 'error: '; echo $this->getRuntimeError (), exit; return $this->getRuntimeError (); } return true; } function toArray () { return array ( 'type' => $this->getType (), 'host' => $this->getHost (), 'port' => $this->getPort (), 'database' => $this->getDatabase (), 'user' => $this->getUser (), 'password' => $this->getPassword (), 'prefix' => $this->getTablePrefix () ); } function _constructErrorHandler ($errno, $errstr, $errfile, $errline) { if(defined('E_DEPRECATED') && $errno == E_DEPRECATED) { return false; } $this->setRuntimeError ($errstr); return true; } protected function startErrorControl () { $this->setRuntimeError (null); set_error_handler (array ( $this, '_constructErrorHandler' )); } function setType ($type) { $this->type = $type; return $this; } function getType () { return $this->type; } public function getHost () { return $this->host; } public function setHost ($host) { $this->host = $host; return $this; } public function getUser () { return $this->user; } public function setUser ($user) { $this->user = $user; return $this; } public function getPassword () { return $this->pass; } public function setPassword ($pass) { $this->pass = $pass; return $this; } public function getDatabase () { return $this->database; } public function setDatabase ($database) { $this->database = $database; return $this; } public function getPort () { return $this->port; } public function setPort ($port) { $this->port = $port; return $this; } protected function finishErrorControl () { restore_error_handler (); } function setTablePrefix ($table_prefix) { $this->table_prefix = $table_prefix; return $this; } function getTablePrefix () { return $this->table_prefix; } private function setRuntimeError ($construction_error) { $this->construction_error = $construction_error; } private function getRuntimeError () { return $this->construction_error; } private function hasRuntimeError () { return isset ($this->construction_error); } }