• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Referring to parent model instance.

Hey guys, so I'm racking my brain over this. I've created a base model that has a lot of reusable code in it that I extend with several other models. I'd like to have some methods with the same name in both the parent model and child model, how would I properly refer to the method in the parent model from the child model if they are named the same. If I use $this->method() it refers to the method in the model its being called from, and I can't seem to get method chaining to work If I'm using parent:: since its static. Anyone have any ideas?

Parent::method() doesn't necessarily mean that the method is static - you can use this just fine (CI uses it all over with the __construct() method). There's a perfect example of calling a parent method of the same name on PHP.net: http://www.php.net/manual/en/language.oop5.basic.php

If that doesn't help, post some of your code and explain what you're trying to do and what is actually happening.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.