public function readcategory($cate_id) { $cate = new Categories_model(); $query = $this->db->get_where('categories', array('id' => $cate_id)); if ($query->num_rows !== 1) { throw new Exception("Cate id {$cate_id} not found in database"); } $rows = $query->result(); $row = $rows[0]; $cate->load($row); return $cate; }