During development, we had to sign a view table of another database, but no matter how hard we tried, only an error occurred. So even though I just called it a simple select, an error occurs.
A Database Error Occurred
Error Number: 1046 No database selected
SELECT * FROM `test1`.`view_test_table`
Filename: test.php
I don't understand this situation.
I've done everything I've asked CodeIgniter document to do, and I've done everything from simple queries to query builder tests, but I can't see the details.
Test_mode.php is:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Test_model extends CI_Model
{
private $new_db;
function __construct()
{
parent::__construct();
$this->new_db = $this->load->database('test1', TRUE);
}
public function test_view_list()
{
$this->new_db->select("*");
$this->new_db->from("test1.view_test_table");
return $this->new_db->get()->result_array();
}
}
and database.php
$db['test1'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'test1',
'password' => 'xxxx',
'database' => '',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
Did I make any mistakes?