Welcome Guest, Not a member yet? Register   Sign In
How do I access the database from a library class?
#1

[eluser]hal10001[/eluser]
I created my own library class, which works fine, but I just can't get connected to the database to run a query. From a function I try to load in the "database" library, but get the following:

Unable to load the requested class: database

This is the basic code:

Code:
class MyClass {

    function myFunction()
    {
        $CI =& get_instance();
        $CI->load->library( 'database' );

        $query = $this->db->query( 'SOME QUERY GOES HERE' );
        return count( $query->result() );
    }
    
}

How do I do this from a library class, and do I need a model, or can I just run the query like normal when using the database class? Thanks!


Messages In This Thread
How do I access the database from a library class? - by El Forum - 02-03-2009, 11:18 PM
How do I access the database from a library class? - by El Forum - 02-03-2009, 11:22 PM
How do I access the database from a library class? - by El Forum - 02-03-2009, 11:24 PM
How do I access the database from a library class? - by El Forum - 02-04-2009, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB