· 8 years ago · Mar 25, 2018, 07:02 AM
1Error Number: 1046
2No database selected
3CREATE TABLE `country` ( `country_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `iso_code_2` varchar(2) NOT NULL, `iso_code_3` varchar(3) NOT NULL, `address_format` text NOT NULL, `postcode_required` tinyint(1) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT ‘1’, PRIMARY KEY (`country_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
4Filename: C:xampphtdocscodeignitersystemdatabaseDB_driver.php
5Line Number: 330
6
7$data['button_continue'] = $this->lang->line('button_continue');
8$data['button_back'] = $this->lang->line('button_back');
9
10if ($this->form_validation->run() == false) {
11 $this->load->view('template/step_3', $data);
12} else {
13 $this->load->model('install/model_install');
14 $this->model_install->database_install();
15 $this->model_install->database_connect();
16 $this->model_install->dump_sql();
17 redirect('step_4');
18
19}
20
21public function dump_sql() {
22 $file = APPPATH . 'modules/install/config/database.sql';
23 if (!file_exists($file)) {
24 exit('Could not load sql file: ' . $file);
25 }
26 $lines = file($file);
27 if ($lines) {
28 $sql = '';
29 foreach($lines as $line) {
30 if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
31 $sql .= $line;
32 if (preg_match('/;s*$/', $line)) {
33 $sql = str_replace("DROP TABLE IF EXISTS `", "DROP TABLE IF EXISTS `" . $this->input->post('dbprefix'), $sql);
34 $sql = str_replace("CREATE TABLE IF NOT EXISTS `", "CREATE TABLE IF NOT EXISTS `" . $this->input->post('dbprefix'), $sql);
35 $sql = str_replace("CREATE TABLE `", "CREATE TABLE `" . $this->input->post('dbprefix'), $sql);
36 $sql = str_replace("INSERT INTO `", "INSERT INTO `" . $this->input->post('dbprefix'), $sql);
37 $this->db->query($sql);
38 $sql = '';
39 }
40 }
41 }
42 }
43 }
44
45if ($this->form_validation->run() == false) {
46 $this->load->view('template/step_3', $data);
47} else {
48 $this->load->model('install/model_install');
49 $this->model_install->database_install();
50 if($this->load->database()) {
51 $this->model_install->dump_sql();
52 redirect('step_4');
53 } else {
54 echo "Could Not Load SQL File"; die;
55 }
56}
57
58public function dump_sql() {
59 $file = APPPATH . 'modules/install/config/database.sql';
60 if (!file_exists($file)) {
61 exit('Could not load sql file: ' . $file);
62 }
63 $lines = file($file);
64 if ($lines) {
65 $sql = '';
66 foreach($lines as $line) {
67 if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
68 $sql .= $line;
69 if (preg_match('/;s*$/', $line)) {
70 $sql = str_replace("DROP TABLE IF EXISTS `", "DROP TABLE IF EXISTS `" . $this->input->post('dbprefix'), $sql);
71 $sql = str_replace("CREATE TABLE IF NOT EXISTS `", "CREATE TABLE IF NOT EXISTS `" . $this->input->post('dbprefix'), $sql);
72 $sql = str_replace("CREATE TABLE `", "CREATE TABLE `" . $this->input->post('dbprefix'), $sql);
73 $sql = str_replace("INSERT INTO `", "INSERT INTO `" . $this->input->post('dbprefix'), $sql);
74 $this->db->query($sql);
75 $sql = '';
76 }
77 }
78 }
79 }
80}
81
82$db['bank_sys'] = array(
83 'dsn' => 'mysql:hostname=localhost;dbname=dba_bank_sys',
84
85$db['bank_sys'] = array(
86 'dsn' => 'sqlsrv:hostname=localhost;database=dba_bank_sys',
87
88$db['default'] = array('hostname' => 'localhost',
89'username' => 'root',
90'password' => '',
91'database' => 'your_database_name',