Check whether model is loaded or not.

Following function will check whether model is loaded in codeigniter. Pass the model name as argument to the following function.

function is_model_loaded($model)
    $ci =& get_instance();      
    $load_arr = (array) $ci->load;

    $mod_arr = array();
    foreach ($load_arr as $key => $value)
        if (substr(trim($key), 2, 50) == "_ci_models")
            $mod_arr = $value;

    if (in_array($model, $mod_arr))
        return TRUE;

    return FALSE;


Popular posts from this blog

Fatal: LoadModule: error loading module 'mod_sql_mysql.c'

Regular Expression Route Constraints And Route Names in Laravel 5.4