Welcome Guest, Not a member yet? Register   Sign In
model's constructor with parameters
#6

(This post was last modified: 04-06-2015, 01:59 AM by casa.)

thanks.
i suppose an example like this :
PHP Code:
// ______________________
//   class
class Test extends CI_Model
{
  
// example of attributes
  
private $items ;
  private 
$key ;

  
// base constructor
  
public function __construct()
  {
    
parent::__construct();
    
$this->key $this->session->userdata('key_value') ;
  }
  
  
// my personnal "constructor"
  
public function make($params)
  {
     
$this->items $params ;
  }
   
// getter and setter
  
public function getItems() { return $this->items ; }

// end of class

//_________________________
// in controller or view
  
$this->load->model('Test') ; // if model is not loaded
  
$params 'titi' ;
  
$r = new Test() ; // or $r = new Test ;
  
$r->make($params) ; 
Have a good day.
Reply


Messages In This Thread
model's constructor with parameters - by casa - 04-05-2015, 10:33 AM
RE: model's constructor with parameters - by casa - 04-05-2015, 09:01 PM
RE: model's constructor with parameters - by s4if - 04-06-2015, 12:18 AM
RE: model's constructor with parameters - by casa - 04-06-2015, 01:57 AM
RE: model's constructor with parameters - by casa - 04-06-2015, 02:23 AM
RE: model's constructor with parameters - by casa - 04-06-2015, 04:55 AM
RE: model's constructor with parameters - by casa - 04-07-2015, 04:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB