0

我在一个项目中有两个数据库。我正在尝试连接第二个数据库以生成一个查询,但它在我的控制台上抛出错误。请帮我解决这个问题

下面我使用的模型代码

//---------connecting with 2nd db--------------------------------------------
public function fetch_all_approved_template_list($limit,$start) 
  {
    $dsn = 'mysql://fitappweb:fitappweb@localhost/fitneapp_webapp'; 
    $dsnDB = $this->load->database($dsn, TRUE);
    $dsnDB->limit($limit, $start);
    $query = $dsnDB->order_by('routine_id', 'DESC')->join('userdetails', 'userdetails.user_id = template_routines.creater_id')->get_where('template_routines',array('status_code'=>'1')); 
    $data=array();
    if ($query->num_rows() > 0) 
     {
        foreach ($query->result() as $row) {
            $data[] = $row;
        }
        return $data;
     }
    return false; 
 }

浏览器窗口上的错误

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

警告:include(application/errors/error_php.php): failed to open stream: No such file or directory in D:\xampp\htdocs\system\core\Exceptions.php on line 182

警告:include():在 D:\xampp\htdocs\system\core\Exceptions.php 中打开 'application/errors/error_php.php' 以包含 (include_path='.;D:\xampp\php\PEAR') 失败在第 182 行

4

3 回答 3

1

您是否尝试在配置文件中设置组名?

之后,您只需要通过组名调用它

$this->load->database('group_name');

于 2013-10-17T20:36:05.123 回答
1

检查 application/config/databases.php 以设置您的数据库,然后您可以使用加载数据库

$this->load->database('group_name',TRUE);

阅读本文以手动连接:

http://ellislab.com/codeigniter/user-guide/database/connecting.html

加载数据库时需要传递一个数组。

我不建议手动连接,而是您的选择。

于 2013-10-17T20:39:17.947 回答
1

codeigniter 应用程序中的 error_php.php 通常包含:

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: <?php echo $severity; ?></p>
<p>Message:  <?php echo $message; ?></p>
<p>Filename: <?php echo $filepath; ?></p>
<p>Line Number: <?php echo $line; ?></p>

</div>

你可以把它放在你的 application/errors/error_php.php 文件中。您将获得有关生成的错误的更多详细信息。

于 2013-10-17T21:12:55.457 回答