I am using CodeIgniter, I am returning more than one value in the model so I did like
return array('true' =>1,'customer_id' => $result->customer_id);
and In the controller, I am displaying like
$true=$result['true'];
$custId=$result['customer_id'];
So there is no issue in this.
Now let's talk about in details
In the model, I have this logic
//sql query
if ($result) {
if ($result->password_change == 0) {
return array('true' =>1,'customer_id' => $result->customer_id);//multiple returns
}
else{
return $result;
}
}
else{return false;}
In the controller
$result=$this->Member_model->check_data(parameters);
$true=$result['true'];
$custId=$result['customer_id'];
if ($result) {
if($true == 1){
//some code here
}
else{
//some code here
}
}
else{
}
This is my second code.
if ($result) {
if ($result - > password_change == 0) {
if ($result - > id == $id) {
return array('true' => 1, 'customer_id' => $result - > customer_id); //return more then 2
} else {
return false;
}
} else {
if ()) // some condition
{
return (array) $result;
} else {
return false;
}
}
} else {
return false;
}
I am getting the error that
"Message: Cannot use object of type stdClass as array"
Because when returning if condition(from the model) then it's working but when it returns else (I mean $result from the model) then I am getting the error because it is not getting the $result['true'].
Hope you can understand my issue. Would you help me out on this issue?