[eluser]Unknown[/eluser]
also tried closing the connection with
Code:
$this->database->close()
and I would add it to the $db array but the database was just crated. a better code snippet:
controller
Code:
makeuser($u,p$);
create_database($s);
create tables($s);
model
Code:
<?php
class Create_model extends Model{
function Create_model(){
parent::model();
}
function makeuser($user,$pass){
$config['hostname'] = 'localhost';
$config['username'] = 'root';
$config['password'] = 'password';
$config['database'] = 'project';
$config['dbdriver'] = 'mysql';
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$this->load->database($config,false);
$sql='query';
$this->db->query($sql);
$this->db->close();
}
function create_database($shortname){
$config['hostname'] = 'localhost';
$config['username'] = 'root';
$config['password'] = 'password';
$config['database'] = 'project';
$config['dbdriver'] = 'mysql';
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$this->load->database($config,false);
$this->load->dbforge();
$this->dbforge->create_database($shortname);
$this->db->close();
}
function create_tables($shortname){
$config['hostname'] = 'localhost';
$config['username'] = 'root';
$config['password'] = 'password';
$config['database'] = $shortname;
$config['dbdriver'] = 'mysql';
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$this->load->database($config,false);
//tables created here goto project database?
}
thanks again,
brandon