For several models, you can do this:
$models = array( 'menu_model' => 'mmodel', 'user_model' => 'umodel', 'admin_model' => 'amodel', ); foreach ($models as $file => $object_name) { $this->load->model($file, $object_name); }
But, as already mentioned, you can create the file application / core / MY_Loader.php and write your own method for loading models. I think this might work (not verified):
class MY_Loader extends CI_Loader { function model($model, $name = '', $db_conn = FALSE) { if (is_array($model)) { foreach ($model as $file => $object_name) {
Using our variable on top:
$this->load->model($models);
You can also allow the transfer of a single DB connection to an array, but then you need a multidimensional array, not the simple one we used. This is not too often, you still have to do it.
source share