Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DatabaseInfo
- {
- /**
- * データベースの種類
- * @var string
- */
- private $database_type;
- /**
- * データベースサーバー名
- * @var string
- */
- private $database_server;
- /**
- * データベースのポート
- * @var string|int
- */
- private $database_port;
- /**
- * データベースのユーザー名
- * @var string
- */
- private $database_username;
- /**
- * データベースのパスワード
- * @var string
- */
- private $database_password;
- /**
- * データベース名
- * @var string
- */
- private $database_name;
- /**
- * データベースの文字コード
- * @var string
- */
- private $database_charset;
- public function type($dbtype = null)
- {
- $this->database_type = $dbtype;
- return $this;
- }
- public function port($port) {
- $this->database_port = $port;
- return $this;
- }
- public function dbname($dbname = null)
- {
- $this->database_name = $dbname;
- return $this;
- }
- public function charset($charset = null)
- {
- $this->database_charset = $charset;
- return $this;
- }
- public function server($server = null)
- {
- $this->database_server = $server;
- return $this;
- }
- public function username($username = null)
- {
- $this->database_username = $username;
- return $this;
- }
- public function password($password = null)
- {
- $this->database_password = $password;
- return $this;
- }
- public function getDdn()
- {
- if(!isset($this->database_port)){
- return "{$this->database_type}:host={$this->database_server};dbname={$this->database_name};charset={$this->database_charset}";
- }else{
- return "{$this->database_type}:host={$this->database_server};port={$this->database_port};dbname={$this->database_name};charset={$this->database_charset}";
- }
- }
- public function getUserName()
- {
- return $this->database_username;
- }
- public function getPassword()
- {
- return $this->database_password;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement