title: PDOException: You cannot serialize or unserialize PDO instances
body: <p>I tried to cache my User object in PHP with memcache, but I get an error while using PDO. I added a __sleep and a __wakeup function.</p>
  
  <p>User.php</p>
  
  <pre><code>/**
   * @var PDO
   */
  protected $db;
  
  public function __construct()
  {
      $this-&gt;db = getInstanceOf('db');
  }
  
  public function __destruct()
  {
  
  }
  
  public function __sleep()
  {
      return array('db');
  }
  
  public function __wakeup()
  {
      $this-&gt;db = getInstanceOf('db');
  }
  </code></pre>
  
  <p>getInstanceOf('db') returns a pdo object...</p>
  
  <p>Returns the following error:</p>
  
  <blockquote>
    <p>PDOException: You cannot serialize or unserialize PDO instances in /var/www/test/User.php on line 41</p>
  </blockquote>