On 20/07/12 17:44, geste wrote:
I have a business system with a table called "People" and where we retain records of a Person even when they leave our organization. Each record has an "active" attribute that indicated if somebody is active (Duh!).

However, I find myself writing a lot of snippets in controllers that essentially go "WHERE active = '1'" and that seems like it could be a pain and error-prone over time.

What I'd like to do is leave "People" alone but create a new model or model called "Users" that simply flters People for active=1. And maybe a corresponding model that is OldUsers and feteches active=0.

I started to implement something like this at the controller level but then asked myself why not implement at Model level. Does this seems liek a rational approach. Can anyone point to some good examples outside of basic API docs?

Thanks,

Jim

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
You *could* implement this as 2 database views as opposed to tables. So 'Users' and 'OldUsers' would simply be 2 views on the 'People' table.

In MySQL this becomes... CREATE VIEW OldUsers AS SELECT * FROM People WHERE active='0';

OldUsers is then effectively a read-only table and CakePHP is quite happy to generate a model for it.


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to