[eluser]mimran[/eluser]
Hi Cleansugar,
From reading your post I am sensing there are a couple of things unclear for you in that code, so i am going to explain each part and hopefully that should resolve the issue for you.
Firstly lets have a look at your model:
MODEL:
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();
}
}
Explanation:
The code above is essentially taking a parameter (Name) and then inquiring your database table against that name. So if you are familiar with SQL then simply this is what you are doing:
select *
from table1
where name = $name
And that's it. So now what i sense is unclear for you is that you don't have the structure of table in your head and can't picture what you are getting back from this code.
So lets say the table you are inquiring 'table1' it looks like this:
Table1:
Name Gender HaveCar PhoneNumber
John Male Yes 123455
Sara Female No 111111
What your query doing now is:
Lets say you passed ‘John’ as parameter
It is returning the whole row as an array which includes (john, male, yes, 123455)
So that was your model.
Now controller is sampling calling this function in your model and getting this full array.
I hope that clarifies any doubts you had.
Regards
mimran