Driver_Database_Driver_MySQLI::create_database
boolean Driver_Database_Driver_MySQLI::create_database( string $database [, string $charset = null , string $collate = null ] )
- throws
- Exception
参数列表
参数 |
类型 |
描述 |
默认值 |
$database |
string |
$database |
|
$charset |
string |
编码,不传则使用数据库连接配置相同到编码 |
null |
$collate |
string |
整理格式 |
null |
返回值
File: ./drivers/database/mysqli/mysqli.class.php
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | public function create_database( $database , $charset = null, $collate =null)
{
$config = $this ->config;
$this ->config[ 'connection' ][ 'database' ] = null;
if (! $charset )
{
$charset = $this ->config[ 'charset' ];
}
$sql = 'CREATE DATABASE ' . $this ->_quote_identifier( $database ). ' DEFAULT CHARACTER SET ' . $charset ;
if ( $collate )
{
$sql .= ' COLLATE ' . $collate ;
}
try
{
$result = $this ->query( $sql , null, true)->result();
$this ->config = $config ;
return $result ;
}
catch (Exception $e )
{
$this ->config = $config ;
throw $e ;
}
}
|