【发布时间】:2019-05-23 03:40:56
【问题描述】:
在开发过程中,我们不得不对另一个数据库的视图表进行签名,但无论我们多么努力,都只是出现了错误。因此,即使我只是将其称为简单选择,也会发生错误。
发生数据库错误
错误号:1046 未选择数据库
SELECT * FROM `test1`.`view_test_table`文件名:test.php
我不明白这种情况。
我已经完成了我要求 CodeIgniter 文档做的所有事情,并且我已经完成了从简单查询到查询构建器测试的所有事情,但是我看不到详细信息。
Test_mode.php 是:
<?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();
}
}
和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
);
我犯了什么错误吗?
【问题讨论】:
-
您阅读过文档吗?
-
你看过这个吗? stackoverflow.com/a/8269596
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
-
@halfer - 我认为有一点误解,因为它是第一次使用。从现在开始我会小心的。
-
@Akintunde-Rotimi - codeigniter.com/userguide3/database/index.html
标签: php mysql codeigniter