Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] 'Unable to locate file: mi_model.php' using HMVC
#1

[eluser]DooBie[/eluser]
Hi, i am get same error when i try to view any page if a try to load a model in a controller class.

I have this structure:

Code:
+app_SNR (application folder)
  +config
  +controllers
  +errors
  +helpers
  +hooks
  +language
  +libraries
  +models
  +modules
    +usuarios
      +controllers
        -usuarios.php
      +models
        -usuarios_model.php
      +views
        -usuarios_view.php
  +views
+sistema (system folder)
  +all system folders....

Code in modules/usuarios/controllers/usuarios.php
Code:
class Usuarios extends Controller
{
   public function __construct()
   {
      parent::Controller();
      $this->load->model('Usuarios_model');
   }

   public function index()
   {
      /*
         ... some code...
      */
      $this->load->view('usuarios_view', $datos);
   }
}

Code in modules/usuarios/models/usuarios_model.php
Code:
class Usuarios_model extends Model
{
   public function __construct()
   {
      parent::Model();
   }
   /*
      ... some code ...
   */
}

I put an example (sorry my poor english)
If i go to http://miserver/usuarios i ger this error:
Code:
An Error Was Encountered

Unable to locate the file: Usuarios_model.php

BUT, if i put the usuarios_model.php file in 'app_SNR/models' AND put in 'autoload.php'
Code:
$autoload['model'] = array('Usuarios_model');
Removing this line in 'usuarios.php'
Code:
...
$this->load->model('Usuarios_model');
...

WORK'S perfect! Where's my error?

Thank you very much
#2

[eluser]ivaylok[/eluser]
The problem is that when you use CI's load->model method as you said, it is trying to locate the usuarios_model.php in your models folder, inside your application folder(so in your case it is trying to locate it in app_SNR/models/ ).
So you should probably be extending CI's Loader library (you can do this unless using php4) and creating your own model function, that suits your folder structure.
#3

[eluser]DooBie[/eluser]
First of all, thanks, but, i use HMCV library, and in his documentation said the models folder in modules are viewing by the system, is not need to put the models in app_SNR/models.


And second, if i put the file usuarios_model.php in app_SNR/models folder, i have the same error, only work if put in autoload.php file!!!! this is the problem!
#4

[eluser]ivaylok[/eluser]
Sorry, I misread about using HMVC.
I am quite sure that you will find a solution for your problem if you take a look in this thread, or ask your question there.
#5

[eluser]DooBie[/eluser]
i solved my problem, the error are in this line in usuarios.php:
Code:
$this->load->model('Usuarios_model');

i change with this line:
Code:
$this->load->model('usuarios_model');

Note that 'usuarios_model' are in first lowercase! but, the name of the class are 'Usuarios_model' with first upercase.

Thanks!
#6

[eluser]Unknown[/eluser]
Doobie muchas gracias! tu solución me sirvió para librarme del mismo error que me tenía loco desde hace 3 horas.
---
Thank you Doobie! Your solution helped me to track the error.
#7

[eluser]DooBie[/eluser]
Me alegro haber sido de ayuda.
#8

[eluser]gvillavizar[/eluser]
Wow, a mi tambien me sirvio. Llevo un buen tiempo tratando de solucionar esto y no habia podido, increible que una simple letra mayuscula pudiera tenerme trancado por dos dias con el mismo error.

Gracias!

Edit: Ok, todavia no. Sigo teniendo el problema, estoy haciendo un clean install a ver si asi lo resuelvo.

Edit: Efectivamente, eso resolvio mi error. Gracias.




Theme © iAndrew 2016 - Forum software by © MyBB