Monday, August 30, 2010

Database Views in CakePHP

Hi All,

Just wondering if there is a way to use database views in CakePHP.

Say I want to have a view

CREATE VIEW user_view_{$user_id} AS
SELECT *
FROM users, comments
WHERE users.id = comments.user_id
AND users.id = {$user_id} ;

and I also want to have an adhoc model to CRUD on this view (so that I
don't actually need to have a condition 'user_id' = {$user_id}
whenever I need the data. I'm lazy, I know :p but this is just a
simplified example of my somewhat complicated model).

Is there a way to achieve this? I found very little useful results in
Googling for 'cakephp database view', it seems people are quite happy
the way it is. Or am I being 'academic' and missing the point about
the whole view business?

Thanks in advance :)

Char

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: