title: extending PDO as CodeIgniter library
body: <p>I know CI 2.1.3 is now support PDO. but it'll more comfortable for me using pdo functions instead of codeigniter function, and Now I want to extend PDO and use it as library and create PDO object once it loaded by Controller or another library; It is possible, isn't it?, my attempt so far:</p>
  
  <pre><code>class Mypdo extends PDO {
    public function __construct($dsn='mysql:dbname=mydbname;host=localhost',
                                $username='myusername',
                                $password='mypassword',
                                $driver_options=array()) {
          parent::__construct($dsn, $username, $password, $driver_options);
    }
  }
  </code></pre>
  
  <p>and simple usage:</p>
  
  <pre><code>class Otherlibrary{
     var $CI;
     var $something_id;
  
     public function __construct(){
        $this-&gt;CI =&amp; get_instance();
        $this-&gt;CI-&gt;load-&gt;library('mypdo');
  
        $this-&gt;something_id = 'foo';
     }
  
     public function is_something_exist(){
        try{
           $q = "SELECT * FROM something WHERE something_id = '$this-&gt;something_id'";
           $stmt = $this-&gt;CI-&gt;mypdo-&gt;prepare($q); //&lt;--PROBLEM
           $stmt-&gt;execute();
  
           if ($stmt-&gt;rowCount() &lt; 1){
              return false;
            } else {
              return true;
            }
         } catch (PDOException $e){
             echo $e-&gt;getMessage();
         }
      }
  }
  </code></pre>
  
  <p>always return:</p>
  
  <blockquote>
    <p><strong>Fatal error:</strong> Call to a member function prepare() on a non-object in...</p>
  </blockquote>
  
  <p>I'm not expert at all in PHP class/object, so please I need help to improve my code and make it works. Thanks.</p>