codeigniter에서 SQL 파일을 실행하도록 모델을로드 할 때. 선택한 데이터베이스가 없다고 말하는 오류가 발생하지만 거기에 있습니다. 버튼을 클릭하여 다음 단계로 이동하면 오류가 발생합니다. 그것은 어떻게로드 SQL 전에 먼저 데이터베이스를로드해야합니다. 어떻게 작동하게하는지 잘 모르겠습니다.오류 번호 : 1046 데이터베이스가 선택되지 않았습니다 - CodeIgniter
페이지가 새로 고침되면 새로 고침됩니다. 당신은 MySQL을 말할 필요
오류 컨트롤러에
Error Number: 1046
No database selected
CREATE 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;
Filename: C:\xampp\htdocs\codeigniter\system\database\DB_driver.php
Line Number: 330
$data['button_continue'] = $this->lang->line('button_continue');
$data['button_back'] = $this->lang->line('button_back');
if ($this->form_validation->run() == false) {
$this->load->view('template/step_3', $data);
} else {
$this->load->model('install/model_install');
$this->model_install->database_install();
$this->model_install->database_connect();
$this->model_install->dump_sql();
redirect('step_4');
}
모델 버튼을 클릭하는 즉시 수행해야 페이지를 새로
public function dump_sql() {
$file = APPPATH . 'modules/install/config/database.sql';
if (!file_exists($file)) {
exit('Could not load sql file: ' . $file);
}
$lines = file($file);
if ($lines) {
$sql = '';
foreach($lines as $line) {
if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
$sql .= $line;
if (preg_match('/;\s*$/', $line)) {
$sql = str_replace("DROP TABLE IF EXISTS `", "DROP TABLE IF EXISTS `" . $this->input->post('dbprefix'), $sql);
$sql = str_replace("CREATE TABLE IF NOT EXISTS `", "CREATE TABLE IF NOT EXISTS `" . $this->input->post('dbprefix'), $sql);
$sql = str_replace("CREATE TABLE `", "CREATE TABLE `" . $this->input->post('dbprefix'), $sql);
$sql = str_replace("INSERT INTO `", "INSERT INTO `" . $this->input->post('dbprefix'), $sql);
$this->db->query($sql);
$sql = '';
}
}
}
}
}
변경됩니다 드라이버로 SQLSRV 말처럼 뭔가를 사용하고 있습니까? 컨트롤러에? 모델에서? 자동로드 하시겠습니까? 모든 컨트롤러와 모델을 보여주십시오. – Craine
예 모델이 있습니다. 첫 번째 게시물에 모델 함수를 추가했습니다. –