Q:

Check it is empty or not in codeigniter

I am working in codeigniter. I have created one function in model. The function is like this : 
function pr($id)
    {
        //$query5 = $this->db->query("select max(to_date) as last_date from agent_print_details where agent_id = ".$id);
        //$result5 = $query5->result();

        $this->db->select('max(to_date) as last_date');
        $this->db->from('agent_print_details');
        $this->db->where('agent_id',$id);

        $result = $this->db->get();

        if($result->num_rows()>0)

        return $result->result();

        else

        return "empty";

    }

my controller is : 
$pr_detail = $this->cashier1_model->pr($role['id']);

if($pr_detail ! = 0)
{
    echo "nisarg";
}
else
{
    echo "123";
}

when I print pr_detail then it will display output like this:
Array ( [0] => stdClass Object ( [last_date] => ) ) 

it will give blank data so it has to print 123 but it is display nisarg.  
So What should i have to do to print 123? 

A:

If result not found just return FALSE in model file.  Also use CI select_max to get max value
MODEL
$this->db->select_max('to_date','last_date');
$this->db->from('agent_print_details');
$this->db->where('agent_id', $id);
$result = $this->db->get();
if ($result->num_rows() > 0) {
    return $result->result();
} else {
    return FALSE;
}

CONTROLLER
$pr_detail = $this->cashier1_model->pr($role['id']);

if($pr_detail)
{
    echo "nisarg";
}
else
{
    echo "123";
}

