title: Use a database view for a model in CakePHP 2.0
body: <p>After upgrading from Cake 1.3 to 2.0 I I'm getting missing table errors for all my models that use database <em>views</em> rather than tables. My models using tables still work fine. Changing these models to use tables fixes the problem, but I need views.</p>
  
  <p>In the past this worked, as <a href="https://stackoverflow.com/questions/949399/cakephp-is-it-possible-to-associate-a-model-with-a-database-view-instead-of-a-t">this question shows</a>; views worked just like tables. However after moving to Cake 2.0 I get:</p>
  
  <blockquote>
    <p>Error: Database table myView for model myModel was not found</p>
  </blockquote>
  
  <p>Here's an example Model class:</p>
  
  <pre><code>class Hauler extends AppModel
  {
      var $useTable = 'hauler_view';
      var $primaryKey = 'id';
      var $useDbConfig = 'default';
  }
  </code></pre>
  
  <p>The view <code>hauler_view</code> exists and worked in the app in 1.3. Copying the same data from the view into a physical table will work if I set the model to read that physical table instead. </p>
  
  <p>I've confirmed I can access database views via Cake's raw SQL functions, so I <em>can</em> access those views, it's just that the Models aren't seeing the "tables".</p>
  
  <p>I'm using SQL Server 2005 with the sqlsrv driver if that matters. I have the SQL Server 2008 Native Client installed on my server which allows this version of cake to access SQL Server.</p>
  
  <p><strong>Is there some way to let Models in CakePHP 2.0 use views rather than tables?</strong></p>
  
  <p>I solved <a href="https://stackoverflow.com/questions/9040997/pdo-sql-server-extension-faulting-intermittently">this related problem</a> so I now know my database driver is functioning properly and is not the problem.</p>