CodeIgniter and autoloading the database library

后端 未结 7 1014
小鲜肉
小鲜肉 2021-01-21 04:19

I\'ve got an issue connecting to the database with CodeIgniter.

In the model, if I do

$this->load->database();

then a query such

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-21 04:37

    You could try PHP Autoload Class Magic function in this case.

        function __autoload($class)
    {
        if(strpos($class, 'CI_') !== 0)
        {
            @include_once( APPPATH . 'libraries/'. $class . '.php' );
        }
    }
    

    This code must copied inside the config.php (after the last line) within Application folder.

    This code will automatically load libraries for you when its needed.

    It might work. Happy coding.

提交回复
热议问题