public function exists($id) { $select = $this->db->select(['COUNT(*)'])->from('main_table', $this->getMainTable())->where('main_table.' . $this->getPrimaryKey() . '=?', $id); return $select->fetchValue(); }