Welcome Guest, Not a member yet? Register   Sign In
Am I using this base model correctly?
#1

[eluser]snifty[/eluser]
I'm still trying to wrap my head around OOP in PHP, it would be great if someone could cluebat me if I'm totally off base here:

I found a really nice base model which takes care of the basic CRUD functionality in models, this one:

https://github.com/jamierumbelow/codeigniter-base-model

Using that I've been able to remove a lot of my model code. But the docs are pretty minimal, so I'm not sure how to go about overriding one of the methods -- say, for instance, I want to customize the insert method in my application/models/foo.php:

Code:
class Phrase_model extends MY_Model { // MY_Model is the one from the link

  public function __constructor(){
    parent::__construct();
  }

  public function insert($data){
    // do my stuff to $data
    parent::insert($data);
  }

That seems to work -- am I on the right track?

Thanks!
#2

[eluser]Eric Barnes[/eluser]
Yes I find the way you did it the easiest. Especially when I go to view it later Smile

Another option could be to tie into the before_create part of that file.
#3

[eluser]snifty[/eluser]
Thanks Eric!

And as long as I have your attention thanks for working on Codeigniter, it's awesome. Smile




Theme © iAndrew 2016 - Forum software by © MyBB