[eluser]hal10001[/eluser]
[quote author="hal10001" date="1233746328"]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![/quote]
Thank you for your help on this. It was a combination of things that you both mentioned. I ended up with the following:
Code:
class MyClass {
function myFunction()
{
$CI =& get_instance();
$db = $CI->load->database( 'default', TRUE );
$query = $db->query( 'SOME QUERY GOES HERE' );
return count( $query->result() );
}
}