CodeIgniter Forums
CI 1.6.3 issues with DBUtil - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: CI 1.6.3 issues with DBUtil (/thread-15403.html)



CI 1.6.3 issues with DBUtil - El Forum - 02-03-2009

[eluser]jtkendall[/eluser]
Hi, I'm trying to load the DBUtil class so that I can export a CSV of a DB query, however when I load the class in my controller I get an error stating:

Quote:Fatal error: Call to undefined method Export::_ci_assign_to_models() in /Library/WebServer/__Frameworks/CodeIgniter/1.6.3/system/libraries/Loader.php on line 276

I get the error regardless of where I try to load the DBUtil class.

My Controller:

Code:
<?php

    class Export extends Controller
    {

        public function __construct()
        {    
            parent::__construct();
            $this->load->dbutil();
        }

        public function index()
        {
            redirect('/ecommerce/reports/');
        }

        public function report($type=NULL, $id=NULL)
        {    
            if($type == null)
                $this->index();

            if($type == 'full')
            {
                $query = $this->crud_model->read('orders', array(), NULL);

                $delimiter    = ",";
                $newline    = "\r\n";
                echo $this->dbutil->csv_from_result($query);
            }
        }

    }

The line the error refers to in the Loader class is:

Code:
$CI->load->_ci_assign_to_models();

The full function where the error occurs:

Code:
/**
     * Load the Database Forge Class
     *
     * @access    public
     * @return    string        
     */        
    function dbforge()
    {
        if ( ! class_exists('CI_DB'))
        {
            $this->database();
        }
        
        $CI =& get_instance();
    
        require_once(BASEPATH.'database/DB_forge'.EXT);
        require_once(BASEPATH.'database/drivers/'.$CI->db->dbdriver.'/'.$CI->db->dbdriver.'_forge'.EXT);
        $class = 'CI_DB_'.$CI->db->dbdriver.'_forge';

        $CI->dbforge = new $class();
        
        $CI->load->_ci_assign_to_models();
    }

Any help would be appreciated. Thanks.


EDIT: I just switched my app to point to my 1.7.0 setup and same error, just a different line (looks like a few lines were added before the function in the file) 283


CI 1.6.3 issues with DBUtil - El Forum - 02-03-2009

[eluser]jtkendall[/eluser]
Ok, just tried it on a completely different app and it works using both the 1.7.0 and 1.6.3 system folders. The only thing different on the app it won't work on is that it's using HMVC (ME) and there is a Controller.php file with that in the Application/libraries/ folder.


CI 1.6.3 issues with DBUtil - El Forum - 02-04-2009

[eluser]jtkendall[/eluser]
Solved this, with HMVC (ME)version 4.2.06 I had to rename Controller.php in the application/libraries folder to MY_Controller.php (duh) and then have all of my controllers extend it instead of Controller, except the one controller that has the DBUtil calls. It still extends Controller.