ライブラリの中でCodeIgniter組み込みのクラスを使う場合

class Hoge {
  var  $CI;
  function __constructor() {
    $CI =& get_instance();
  }
  function somefunc($id) {
    $this->CI->db->get_where($table_name, array('id' =>$id));
    
    // 何か処理
  }
}

みたいにインスタンスを取らないといけない。
コントローラ内でCodeIgniter組み込みのクラスを使う場合は、

$this->db->get_where($table_name, array('id' => $id);

と、$thisからアクセスできる。