Monday, December 28, 2009

Re: How to setup relationships in model User has a Status

AFAIK,
In general we have three statuses for every account
created but not active (0)
activated (1)
banned (-1)

It is better to stick to one table (users), so this table have an
indexed integer field called status.

As for "Active", ''Banned", etc...
It is just a convention and 9X% of the queries around the users table
do not need those strings. just because I don't want to say 100%
(because I hate the number 100)

On Dec 28, 1:24 am, Brettski <brettsk...@gmail.com> wrote:
> Hi,
>
> Just learning CakePHP now.
>
> I have a simple question, hopefully its a simple answer :)
>
> I'm trying to get my models setup right, so I have a user model, and a
> status model, for example..
>
> Status = "Active" or "Cancelled" etc.
>
> I can't seem to get the associations right.
>
> How do you set each of these up so that I return an array of status's
> to the user model.
>
> I thought it would be User hasOne Status, Status hasMany Users but
> that doesn't work, it looks for a Status.user_id which isn't a field
> (as it doesn't make sense).
>
> b

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: