original_string: public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
          $driverstatus = $this->driver_installed();
  
          if ($driverstatus !== true) {
              throw new dml_exception('dbdriverproblem', $driverstatus);
          }
  
          if (!empty($dboptions['dbsocket'])
                  and (strpos($dboptions['dbsocket'], '/') !== false or strpos($dboptions['dbsocket'], '\\') !== false)) {
              $dbsocket = $dboptions['dbsocket'];
          } else {
              $dbsocket = ini_get('mysqli.default_socket');
          }
          if (empty($dboptions['dbport'])) {
              $dbport = (int)ini_get('mysqli.default_port');
          } else {
              $dbport = (int)$dboptions['dbport'];
          }
          // verify ini.get does not return nonsense
          if (empty($dbport)) {
              $dbport = 3306;
          }
          ob_start();
          $conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport, $dbsocket); // Connect without db
          $dberr = ob_get_contents();
          ob_end_clean();
          $errorno = @$conn->connect_errno;
  
          if ($errorno !== 0) {
              throw new dml_connection_exception($dberr);
          }
  
          // Normally a check would be done before setting utf8mb4, but the database can be created
          // before the enviroment checks are done. We'll proceed with creating the database and then do checks next.
          $charset = 'utf8mb4';
          if (isset($dboptions['dbcollation']) and (strpos($dboptions['dbcollation'], 'utf8_') === 0
                  || strpos($dboptions['dbcollation'], 'utf8mb4_') === 0)) {
              $collation = $dboptions['dbcollation'];
              $collationinfo = explode('_', $dboptions['dbcollation']);
              $charset = reset($collationinfo);
          } else {
              $collation = 'utf8mb4_unicode_ci';
          }
  
          $result = $conn->query("CREATE DATABASE $dbname DEFAULT CHARACTER SET $charset DEFAULT COLLATE ".$collation);
  
          $conn->close();
  
          if (!$result) {
              throw new dml_exception('cannotcreatedb');
          }
  
          return true;
      }
code: public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
          $driverstatus = $this->driver_installed();
  
          if ($driverstatus !== true) {
              throw new dml_exception('dbdriverproblem', $driverstatus);
          }
  
          if (!empty($dboptions['dbsocket'])
                  and (strpos($dboptions['dbsocket'], '/') !== false or strpos($dboptions['dbsocket'], '\\') !== false)) {
              $dbsocket = $dboptions['dbsocket'];
          } else {
              $dbsocket = ini_get('mysqli.default_socket');
          }
          if (empty($dboptions['dbport'])) {
              $dbport = (int)ini_get('mysqli.default_port');
          } else {
              $dbport = (int)$dboptions['dbport'];
          }
          // verify ini.get does not return nonsense
          if (empty($dbport)) {
              $dbport = 3306;
          }
          ob_start();
          $conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport, $dbsocket); // Connect without db
          $dberr = ob_get_contents();
          ob_end_clean();
          $errorno = @$conn->connect_errno;
  
          if ($errorno !== 0) {
              throw new dml_connection_exception($dberr);
          }
  
          // Normally a check would be done before setting utf8mb4, but the database can be created
          // before the enviroment checks are done. We'll proceed with creating the database and then do checks next.
          $charset = 'utf8mb4';
          if (isset($dboptions['dbcollation']) and (strpos($dboptions['dbcollation'], 'utf8_') === 0
                  || strpos($dboptions['dbcollation'], 'utf8mb4_') === 0)) {
              $collation = $dboptions['dbcollation'];
              $collationinfo = explode('_', $dboptions['dbcollation']);
              $charset = reset($collationinfo);
          } else {
              $collation = 'utf8mb4_unicode_ci';
          }
  
          $result = $conn->query("CREATE DATABASE $dbname DEFAULT CHARACTER SET $charset DEFAULT COLLATE ".$collation);
  
          $conn->close();
  
          if (!$result) {
              throw new dml_exception('cannotcreatedb');
          }
  
          return true;
      }
code_tokens: public function create_database ( $ dbhost , $ dbuser , $ dbpass , $ dbname , array $ dboptions = null ) { $ driverstatus = $ this -> driver_installed ( ) ; if ( $ driverstatus !== true ) { throw new dml_exception ( 'dbdriverproblem' , $ driverstatus ) ; } if ( ! empty ( $ dboptions [ 'dbsocket' ] ) and ( strpos ( $ dboptions [ 'dbsocket' ] , '/' ) !== false or strpos ( $ dboptions [ 'dbsocket' ] , '\\' ) !== false ) ) { $ dbsocket = $ dboptions [ 'dbsocket' ] ; } else { $ dbsocket = ini_get ( 'mysqli.default_socket' ) ; } if ( empty ( $ dboptions [ 'dbport' ] ) ) { $ dbport = ( int ) ini_get ( 'mysqli.default_port' ) ; } else { $ dbport = ( int ) $ dboptions [ 'dbport' ] ; } // verify ini.get does not return nonsense if ( empty ( $ dbport ) ) { $ dbport = 3306 ; } ob_start ( ) ; $ conn = new mysqli ( $ dbhost , $ dbuser , $ dbpass , '' , $ dbport , $ dbsocket ) ; // Connect without db $ dberr = ob_get_contents ( ) ; ob_end_clean ( ) ; $ errorno = @ $ conn -> connect_errno ; if ( $ errorno !== 0 ) { throw new dml_connection_exception ( $ dberr ) ; } // Normally a check would be done before setting utf8mb4, but the database can be created // before the enviroment checks are done. We'll proceed with creating the database and then do checks next. $ charset = 'utf8mb4' ; if ( isset ( $ dboptions [ 'dbcollation' ] ) and ( strpos ( $ dboptions [ 'dbcollation' ] , 'utf8_' ) === 0 || strpos ( $ dboptions [ 'dbcollation' ] , 'utf8mb4_' ) === 0 ) ) { $ collation = $ dboptions [ 'dbcollation' ] ; $ collationinfo = explode ( '_' , $ dboptions [ 'dbcollation' ] ) ; $ charset = reset ( $ collationinfo ) ; } else { $ collation = 'utf8mb4_unicode_ci' ; } $ result = $ conn -> query ( "CREATE DATABASE $dbname DEFAULT CHARACTER SET $charset DEFAULT COLLATE " . $ collation ) ; $ conn -> close ( ) ; if ( ! $ result ) { throw new dml_exception ( 'cannotcreatedb' ) ; } return true ; }
docstring: Attempt to create the database
  @param string $dbhost
  @param string $dbuser
  @param string $dbpass
  @param string $dbname
  @return bool success
  @throws dml_exception A DML specific exception is thrown for any errors.
docstring_tokens: Attempt to create the database