Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Model not found!
  • I've got a model called
    Model_user.php
    
    <?php
    
    class Model_user extends Orm\Model {
    
     protected static $_properties = array('user_id', 'user_email', 'user_name');
     protected static $_primary_key = array('user_id');
    
    }
    

    I've enabled
    orm
    
    in app/.../config.php Then I call
    $user_id = Model_User::factory($new_user)->save();
    

    And I get
    ErrorException [ Error ]: Class 'Model_User' not found
    
    APPPATH/classes/controller/sign.php @ line 42
    
    (referring to above) Backtrace: COREPATH/base.php @ line 178 Any ideas?
  • I am also cacing the same problem. I have created a module and calling model inside it.
    Here is the model code
    <?php namespace ipage;
    class Model_Info extends \Orm\Model {
    protected static $_properties = array(
    'id' => array('type'=>'int'),
    'key' => array(
    'type' => 'varchar',
    'label' => 'Info Key',
    'validation' => array('required', 'min_length' => array(3), 'max_length' => array(15))
    ),
    'value' => array(
    'type' => 'varchar',
    'label' => 'Info Value',
    'validation' => array('required', 'min_length' => array(3), 'max_length' => array(40))
    )
    );
    protected static $_table_name = 'ipage_info';
    protected static $_primary_key = array('id');
    } ?>
    I am colling it in controller like : Model_Info::find()->where('key', 'total_categories')->get_one();
    Getting error:
    APPPATH/modules/ipage/classes/controller/admin/categories.php @ line 13
  • I saw an issue flying by today about case issues in the autoloader, related to models in a module. You might want to update to the develop branch to see if that fixes your issue too.
  • hey,
    the only error I see is that file should be called user.php
  • Jaroslav Petrusevic wrote on Monday 1st of August 2011:
    hey,
    the only error I see is that file should be called user.php

    and
    class Model_user extends Orm\Model { protected static $_properties = array('user_id', 'user_email', 'user_name'); protected static $_primary_key = array('user_id'); }
    

    Model_user should be Model_User
  • Bingo! I read "Creating a model takes little time, the convention is to use the Model_ prefix and thus place them in app/classes/model/ but you are free to use whatever name you choose." in the Docs as meaning give it a filename of Model_ and put it in that folder. D'oh! Thanks guys.

Howdy, Stranger!

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

In this Discussion