コード例 #1
0
ファイル: MysqlLayer.php プロジェクト: skullab/thunderhawk
 public function createDb()
 {
     if (!$this->_dbExist) {
         $mysqli = new \mysqli($this->_mDescriptor['host'], $this->_mDescriptor['username'], $this->_mDescriptor['password']);
         if ($mysqli->connect_error) {
             die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
         }
         $this->_mHostInfo = $mysqli->host_info;
         $sql = 'CREATE DATABASE IF NOT EXISTS ' . $this->_mDescriptor['dbname'];
         if (!$mysqli->query($sql)) {
             $mysqli->close();
             die("DB creation failed: (" . $mysqli->errno . ") " . $mysqli->error);
         }
         $mysqli->close();
         $this->_dbExist = true;
         parent::__construct($this->_mDescriptor);
     }
 }