[eluser]cleansugar[/eluser]
controller:
Code:
function detail($name)
{
$data['result'] = $this->hello_model->getDetail($name);
foreach ($data['result'] as $row)
{
if ($row->sex == 0){
$row->sex = 'female';
}else{
$row->sex = 'male';
};
}
foreach ($data['result'] as $row)
{
if ($row->bigo != null){
$this->load->view('bigodetail_view',$data);
}else{
$this->load->view('detail_view',$data);
};
}
model:
Code:
function getDetail($name)
{
$this->db->where('name', $name);
$query = $this->db->get('table1');
if ($query->num_rows() == 0)
{
//show_error('Database is empty!');
}else{
return $query->result();
}
}
if $row->sex 0 female, 1->male.
Did I do a right programming? changing $data['result'] is not thought as right.
If I want to make and add to this obeject another sex1 property(sex1 is string like 'male' or 'female'), what can I do?
And In controller, foreach is required to read $data['result']?
Any other way like $data['result']['sex'][n] does not exist?
Please help...