Welcome Guest, Not a member yet? Register   Sign In
Problem with extended Model
#11

[eluser]christian studer[/eluser]
[quote author="xwero" date="1234206162"]The parent constructor in the MY_model class constructor needs to be parent::Model(). The Model class has no __construct method.

The MY_ prefix classes extends the base class in a hidden way and are autoloaded. So your actual model classes have to extend the model class instead of the MY_ class.

If you make those changes everything should work.[/quote]

No, it doesn't. Now getValue() is known, but the method loadSimpleTable is no longer aviable from Hubconfig, since this class doesn't extend MY_Model anymore.

BTW: __construct exist, it's a magic method and automatically calls the function Model() in class Model. (This is PHP5-style.)
#12

[eluser]christian studer[/eluser]
[quote author="TheFuzzy0ne" date="1234206781"]
Perhaps I am misunderstanding what you are saying.
[/quote]

Yes, you were misunderstanding me: the $this->load->model('tralala');-function is case insensitive, but the calls to the model ($this->Tralala) isn't.

Thanks anyway,
christian
#13

[eluser]xwero[/eluser]
You are right the MY_Model class isn't autoloaded so a way to tackle this is to include the MY_Model class in your Hubconfig class file. The problem then is that you can't load two models that extend the MY_Model class.
#14

[eluser]christian studer[/eluser]
Too bad.

Thanks for your help anyway. I'll use one of my workarounds (Loading the class myself or putting the additional methods into a plugin/helper).
#15

[eluser]TheFuzzy0ne[/eluser]
I don't get it... All I did was change $this->Hubconfig->getValue('hubname') to $this->hubconfig->getValue('hubname'), and it worked. As far as I am concerned, the issue is solved, unless there is a new problem I'm not aware of.

The model is available as $this->hubconfig not $this->Hubconfig as it's written in your code... Unless, as I said before, you supply a second parameter to the model loader.
#16

[eluser]christian studer[/eluser]
GRR.

I didn't spot the error and it's little comfort to me that no one else did: The problem wasn't my model, it was that I tried loading it in the view and not in the controller. :-(

It's working now.
#17

[eluser]TheFuzzy0ne[/eluser]
Although it's not considered good practice, you should be able to load a model from within a view, no problem.

Anyway, glad you got it sorted.
#18

[eluser]SitesByJoe[/eluser]
You should be ashamed of yourself, loading models in views... how dare you!




Theme © iAndrew 2016 - Forum software by © MyBB