Welcome Guest, Not a member yet? Register   Sign In
database config file
#1

[eluser]cinewbie81[/eluser]
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 ??


Messages In This Thread
database config file - by El Forum - 10-15-2007, 06:37 AM
database config file - by El Forum - 10-15-2007, 08:48 AM
database config file - by El Forum - 10-15-2007, 09:35 AM
database config file - by El Forum - 10-15-2007, 06:38 PM
database config file - by El Forum - 10-17-2007, 08:07 PM
database config file - by El Forum - 10-17-2007, 08:32 PM
database config file - by El Forum - 10-17-2007, 09:48 PM
database config file - by El Forum - 10-19-2007, 05:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB