[eluser]cinewbie81[/eluser]
Hi all,
Sorry i post it on another forum previously, think that this is the right forum for me to post.. so here's it again ::
[quote author="cinewbie81" date="1192469868"]Hi all,
The following is my setup.php controller clas:
Code:
class Setup extends Controller {
function Setup()
{
parent::Controller();
$this->load->helper(array('url','form','setting'));
$this->load->model('dbmodel', 'sql', TRUE);
$this->load->database();
}
function index()
{
$this->load->dbutil();
if ($this->dbutil->create_database('payroll')) {
echo 'Database created!';
}
}
}
And the following is my database.php config:
Code:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "password";
$db['default']['database'] = "payroll";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
When function index() loaded, the following error message prompted out:
"Unable to select the specified database: payroll"
This error is because I bind the value 'payroll' to $db['default']['database'] in my config file. It can be easily fixed if i manually query 'Create Database payroll' in prior, but i don't want it to be this way cause i don't want all my client have to manually create the database first before they can use the system. Any solution ??[/quote]