After upgrading from Cake 1.3 to 2.0 I I'm getting missing table errors for all my models that use database views rather than tables. My models using tables still work fine. Changing these models to use tables fixes the problem, but I need views.
In the past this worked, as this question shows; views worked just like tables. However after moving to Cake 2.0 I get:
Error: Database table myView for model myModel was not found
Here's an example Model class:
class Hauler extends AppModel
{
var $useTable = 'hauler_view';
var $primaryKey = 'id';
var $useDbConfig = 'default';
}
The view hauler_view 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.
I've confirmed I can access database views via Cake's raw SQL functions, so I can access those views, it's just that the Models aren't seeing the "tables".
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.
Is there some way to let Models in CakePHP 2.0 use views rather than tables?
I solved this related problem so I now know my database driver is functioning properly and is not the problem.