title: Zend Framework, Doctrine and Caching Problems
body: <p>I'm using Doctrine 1.2 with Zend Framework, and it's working just fine.  Now I want to start using the results cache and query caching capabilities to reduce the load on DB server that powers the application.  Oh, I'm also using Zend_Application and placing code in modules.</p>
  
  <p>Anyway, I setup my connections to Doctrine in the overall Bootstrap.php file for the application itself:</p>
  
  <pre><code>protected function _initDoctrine()  
  {  
      Zend_Loader_Autoloader::getInstance()-&gt;registerNamespace('Doctrine')-&gt;pushAutoloader(array('Doctrine', 'autoload'));  
  
      $manager = Doctrine_Manager::getInstance();  
  
      foreach ($this-&gt;_options['doctrine']['attr'] as $key =&gt; $val) {  
          $manager-&gt;setAttribute(constant("Doctrine::$key"), $val);  
      }  
  
      $conn = Doctrine_Manager::connection($this-&gt;_options['doctrine']['dsn'], 'doctrine');  
  
      Doctrine::loadModels($this-&gt;_options["doctrine"]["module_directories"]);  
  }
  </code></pre>
  
  <p>Now, I spent some time reading both the documentation for query and result caching for Doctrine <strong>and</strong> looking for examples of using Doctrine's caching.  What I found appears to be very straightforward.  I added this code to the Bootstrap.php file that contains the _initDoctrine() method, inside _initDoctrine()</p>
  
  <pre><code>    // Set up some caching
      $cacheConn = Doctrine_Manager::connection(new PDO('sqlite::memory:'));
      $cacheDriver = new Doctrine_Cache_Db(array(
          'connection' =&gt; $cacheConn,
          'tableName' =&gt; 'cache'));
      $cacheDriver-&gt;createTable();
      $manager-&gt;setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver);
  </code></pre>
  
  <p>What I am now finding happening is that the entire connection for the application now thinks it is using Sqlite instead of MySQL like it is supposed to.  Which seems odd, since I am only setting the ATTR_QUERY_CACHE attribute.</p>
  
  <p>Tips on resolving this would be greatly appreciated.</p>