连接到数据库时Codeigniter嵌套循环错误

时间:2015-04-20 18:01:14

标签: php sql-server apache codeigniter

我正在阅读用户指南中的Codeigniter教程,但是当我使用模型进入该部分时,我收到一条错误消息,指出执行超时。我随后将php执行时间增加到1200,下一个错误是最大嵌套级别已达到100,我随后将其增加到200并出现相同的错误。

它似乎停留在某种嵌套循环中,只是反复引用相同的4个函数。

我正在跑步: Codeigniter 3.0.0 Apache 2.4.9 PHP 5.5.12 SQL Server 2012 Express LocalDB - (Windows身份验证 - 如果这有所不同)

以下错误信息的一部分:

Fatal error: Maximum function nesting level of '200' reached, aborting! in C:\wamp\www\NewsApp\system\database\DB_driver.php on line 963

Call Stack
    Time    Memory  Function    Location
1   0.0010  151936  {main}( )   ..\index.php:0
2   0.0030  197064  require_once( 'C:\wamp\www\NewsApp\system\core\CodeIgniter.php' )   ..\index.php:292
3   0.0360  850512  News->__construct( )    ..\CodeIgniter.php:500
4   0.0390  985568  CI_Loader->model( ) ..\News.php:7
5   0.0410  992936  News_model->__construct( )  ..\Loader.php:305
6   0.0410  993224  CI_Loader->database( )  ..\News_model.php:6
7   0.0420  1016048 DB( )   ..\Loader.php:349
8   0.0520  1612760 CI_DB_driver->initialize( ) ..\DB.php:216
9   0.0520  1612904 CI_DB_sqlsrv_driver->db_connect( )  ..\DB_driver.php:401
10  15.0609 1616496 CI_DB_driver->query( )  ..\sqlsrv_driver.php:147
11  15.0609 1616728 CI_DB_driver->simple_query( )   ..\DB_driver.php:642
12  15.0609 1616728 CI_DB_driver->initialize( ) ..\DB_driver.php:768
13  15.0609 1616728 CI_DB_sqlsrv_driver->db_connect( )  ..\DB_driver.php:401
14  30.0707 1617416 CI_DB_driver->query( )  ..\sqlsrv_driver.php:147
15  30.0707 1617560 CI_DB_driver->simple_query( )   ..\DB_driver.php:642
16  30.0707 1617560 CI_DB_driver->initialize( ) ..\DB_driver.php:768
17  30.0707 1617560 CI_DB_sqlsrv_driver->db_connect( )  ..\DB_driver.php:401

这里发生了什么?

模特:

<?php
class News_model extends CI_Model {

    public function __construct()
    {
            $this->load->database();
    }

    public function get_news($slug = FALSE)
    {
            if ($slug === FALSE)
            {
                    $query = $this->db->get('news');
                    return $query->result_array();
            }

            $query = $this->db->get_where('news', array('slug' => $slug));
            return $query->row_array();
    }
}

只需$ this-&gt; load-&gt; database();导致循环。

0 个答案:

没有答案