求大家帮帮忙 怎么弄啊 数据库是能成功的创建 表说找不到数据库 怎么弄 啊 跪求帮忙 谢谢了
function createdb(){
$result = $this->dbforge->create_database('wldatabase');
if ($result)
{
$this->createAdmintable();
echo '创建成功';
}
}
function createtable($table){
//创建表
$this->dbforge->create_table($table, true);
}
//创建admin表
function createAdmintable(){
$fields = array(
'userid' => array(
'type' => 'int',
'constraint' => 9,
'unsigned' => true,
'auto_increment' => true,
),
'username' => array(
'type' => 'varchar',
'constraint' => '50',
),
'password' => array(
'type' => 'varchar',
'constraint' => '50',
),
'typeid' => array(
'type' => 'int',
'constraint' => 9,
'unsigned' => true,
'null' => true,
),
'zname' => array(
'type' => 'varchar',
'constraint' => '50',
'null' => true,
),
'phone' => array(
'type' => 'varchar',
'constarint' => '50',
'null' => true,
),
'email' => array(
'type' => 'varchar',
'constarint' => '100',
'null' => true,
),
'logintime' => array(
'type' => 'datetime',
),
'loginip' => array(
'type' => 'varchar',
'constraint' => '50',
'null' => true,
)
);
//添加字段
$this->dbforge->add_field($fields);
//创建主键
$this->dbforge->add_key('userid', true);
$this->createtable('admin');
}
报错:
A Database Error OccurredError Number: 1046 No database selected CREATE TABLE IF NOT EXISTS `admin` ( `userid` int(9) UNSIGNED NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `typeid` int(9) UNSIGNED NULL, `zname` varchar(50) NULL, `phone` varchar NULL, `email` varchar NULL, `logintime` datetime NOT NULL, `loginip` varchar(50) NULL, PRIMARY KEY `userid` (`userid`) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; Filename: E:\work\CMS_Manager\system\database\DB_driver.php Line Number: 330
|