Welcome Guest, Not a member yet? Register   Sign In
dynamic models
#1

[eluser]Darkbob[/eluser]
Hi,

Is it possible to instanciate models the same way we do with POPO (plain old php object Wink ).

The way I'm doing it right now is by doing a workaround by actually doing a custom class that contains the necessary attributes + a codeigniter model which has the methods Sad ...

I'm sure there is a better way to do this?

thanks
#2

[eluser]Colin Williams[/eluser]
application/models/apple_model.php:

Code:
class Apple_model extends Model {

   var $color = 'red';

  function set_color($color)
  {
    $this->color = $color;
  }

}

controller:

Code:
$this->load->model('apple_model');
$apple = new Apple_model();
$apple->set_color('green');




Theme © iAndrew 2016 - Forum software by © MyBB