Welcome Guest, Not a member yet? Register   Sign In
HowTo: test if Active Records is loaded
#1

[eluser]thinkigniter[/eluser]
I'm developing a "reusable" model that needs to check if 'Active Records' is set in the database config file.

E.G.
Code:
function _fetch( $table = '', $fields = array(), $limit='', $offset='' ){
    
    if(DOES_ACTIVE_RECORDS_EXISTS){
        $this->db->start_cache();
        // Does the table exist in the current Database
        if( $table != '' AND $this->db->table_exists($table) ){
               // ...
               // ...
               //etc. etc.
         }else{
          // ACTIVE_RECORDS_DOES_NOT_EXIST
          return FALSE;
         }

Any ideas?
#2

[eluser]Michael Wales[/eluser]
Code:
if (class_exists('CI_DB_active_record')) {
} else {
}
#3

[eluser]thinkigniter[/eluser]
Thanks Michael.

Thats just what I needed.

Although now I want to know all the classes that are set in CI.

Ahhh! There is no end to the need for knowledge.
#4

[eluser]Michael Wales[/eluser]
In a controller you can do the following to echo out the CodeIgniter super object:
Code:
echo '<pre>';
print_r(get_instance());
echo '</pre>';

Remember, CodeIgniter only loads it's core parts by default - everything else you are telling it what to load. If you need to figure out a class name (like the Active Record one, kind of odd) - just open up that file within the /system directory and check out the class definition.




Theme © iAndrew 2016 - Forum software by © MyBB