Monday, August 30, 2010

Re: Database Views in CakePHP

Cool thanks for your reply.

I have also dug around about it for a bit and realise it might not
always be a good idea to do edit/delete on a view (eg, someone else
takes over the project and starts relying on the views as opposed to
the actual tables), but if index and view works I am happy to give
that a try. Will report back :)

On Aug 31, 3:35 am, Jeremy Burns | Class Outfit
<jeremybu...@classoutfit.com> wrote:
> I have defined views as tables (i.e. set up a model that points to it) and it works great for index/view, but edit/delete is dependent upon the database and view structure - views are often based on more than one table, so are more complex than a single table.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 30 Aug 2010, at 09:08, chargu wrote:
>
>
>
> > 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 sitehttp://cakeqs.organd 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 athttp://groups.google.com/group/cake-php?hl=en

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: