Welcome Guest, Not a member yet? Register   Sign In
Display database table with 1 row without using foreach as $row
#1

[eluser]Volkof[/eluser]
Hi,

If I know that the table I retrieve from database has confirm only 1 row, is it possible to display the desired table columns without using foreach($data['reviews'] as $row)?

For example, I have a Database table with values:

rateID
like
reviewID
userID


Because I am Selecting base on reviewID && userID, I know for sure either nothing is returned or just 1 row is returned. And then I want to display the like value.


Thanks

#2

[eluser]bigbusty[/eluser]
thats fairly easy. In your model just return:

Code:
$this->db->where('id', $id);
$query = $this->db->get($table);

if ($query->num_rows() > 0)
{
    return $query->row();
}

return false;




Theme © iAndrew 2016 - Forum software by © MyBB