[eluser]Joe_Archer[/eluser]
I have a very simple script which I intended to to call via the command line.
It utilises 2 databases, one MySQL and one which is connected over ODBC. when calling the method via a browser, it functions exactly as intended. However when I attempt to call the method via the CLI I get an error returned:
<p>Unable to connect to your database server using the provided settings.</p>
<p>Filename: <path to file>DB_driver.php</p>
<p>Line Number: 124</p>
Here is the database config:
$db['default']['hostname'] = 'DSN';
$db['default']['username'] = 'joe';
$db['default']['password'] = '';
$db['default']['database'] = 'timing';
$db['default']['dbdriver'] = 'odbc';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['my']['hostname'] = '127.0.0.1';
$db['my']['username'] = 'root';
$db['my']['password'] = '';
$db['my']['database'] = 'timing';
$db['my']['dbdriver'] = 'mysql';
$db['my']['dbprefix'] = '';
$db['my']['pconnect'] = TRUE;
$db['my']['db_debug'] = TRUE;
$db['my']['cache_on'] = FALSE;
$db['my']['cachedir'] = '';
$db['my']['char_set'] = 'utf8';
$db['my']['dbcollat'] = 'utf8_general_ci';
$db['my']['swap_pre'] = '';
$db['my']['autoinit'] = TRUE;
$db['my']['stricton'] = FALSE;
here is the controller:
public function index()
{
$this->load->database();
$DB2 = $this->load->database('my', TRUE);
$DB2->query("TRUNCATE TABLE drivers");
$query = "SELECT * FROM Drivers";
$result = $this->db->query($query);
$DB2->insert_batch('drivers', $result->result_array());
}
Any ideas why the database connection would fail over CLI but not the browser?