I am having some problem. I am trying to pass a variable from a controller to a model, but I always get a NULL value ON THE MODEL. Anyone can point out what is wrong with my code?
CONTROLLER
public function test()
{
$this->load->model('model_register');
//ID Creation to be inserted into the database
$country_prefix = $this->model_register->countryprefix();
$org_prefix = $this->model_register->organizationprefix();
$insertion = $this->model_register->insertion();
$userid_base = $country_prefix['0']['c_code'].$org_prefix['0']['id'];
$basenum = "000000000";
$base_length = strlen($basenum);
$id_length = strlen($org_prefix['0']['id']);
$computation = $base_length - $id_length;
$id_base_array = array();
for ($i = 0; $i < $computation; $i++)
{
array_push($id_base_array, "0");
}
$id_base = implode("",$id_base_array);
$userid_admin = $country_prefix['0']['c_code']."ADM".$id_base.$org_prefix['0']['id'];
//Insert Data
//data-mix
$data['userid'] = $userid_base;
$data['baselength'] = strlen($basenum);
$data['id_length'] = strlen($org_prefix['0']['id']);
$data['result'] = $computation;
$data['id_base'] = implode("",$id_base_array);
$data['userid_admin'] = $userid_admin;
$data['insertion'] = $insertion;
$insertion = $this->model_register->insertion($data['userid_admin']);
}
Model
public function insertion($x)
{
$value = $x;
$data = array(
'testid' => $value,
);
$this->db->insert('test',$data);
return $value;
}
When I run this, I get
INSERT INTO `test` (`testid`) VALUES (NULL)