Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Underscore problem? : error Class 'Model_Events_Places' not found (but does exist!)
  • I'm getting the error: "Class 'Model_Events_Places' not found" when trying to do a simple query. (below)  Under the models folder I have "events_places.php" with the correct properties setup and a table called "events_places" setup (with content).  (Below is the query I'm using in my controller.) 

    Anyone know why am I getting this error?  I'm guessing it's an underscore issue but I don't want to change my database structure around the code (or framework limitations).

    $query = Model_Events_Places::query()->get();
  • It is not a limitation of framework, but a feature.

    http://fuelphp.com/docs/general/classes.html#/classes_subdirectories

    The autoloader looks for your class under models/events/places.php. Every underscore means it is in a subdirectory.

    You can bypass this by telling your class name and it paths to the Autoloader.

    http://fuelphp.com/docs/classes/autoloader.html

    Autoloader::add_class('Model_Events_Places', APPPATH . 'classes/models/events_places.php');

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion