Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how can i extend orm model ?
  • how can i extend orm model ? i have in APPPATH -> classes/orm/model.php
    class Model extends \Orm\Model
    {
    
        public static function connection()
        {
            echo 'testing'; die;
            //$class = get_called_class();
            //return property_exists($class, '_connection') ? static::$_connection : null;
    
        }     
    
    }
    

    and in bootstrap.php i have Autoloader::add_classes(array( 'Orm\\Model' => APPPATH . 'classes/orm/model.php' ));
    but dont work. what i do bad ? thanks
  • You can even put your model extension in another package, like I did here: https://github.com/WanWizard/fuel-nestedsets (not finished yet).
  • Harro Verton wrote on Friday 27th of May 2011:
    You can even put your model extension in another package, like I did here: https://github.com/WanWizard/fuel-nestedsets (not finished yet).

    WanWizard, i write you later - my solution is pretty easy and work like sharm :P
  • Because the Orm isn't aliased you can't extend it like other parts of the Fuel core. Just use your class like you defined it, but register it in the bootstrap as "Model" (there's one in the core which you overwrite) and make all your models extend just "Model" instead of Orm\Model. You can also name it to something else, in which case you don't have to register it in the bootstrap.
  • Jelmer Schreuder wrote on Friday 27th of May 2011:
    Because the Orm isn't aliased you can't extend it like other parts of the Fuel core. Just use your class like you defined it, but register it in the bootstrap as "Model" (there's one in the core which you overwrite) and make all your models extend just "Model" instead of Orm\Model. You can also name it to something else, in which case you don't have to register it in the bootstrap.

    What I did without you jelmer ? big thanks again :)

Howdy, Stranger!

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

In this Discussion