Monday, December 28, 2009

convention clarifications, and joins with cakephp

hi,
just few days ago i found out about this miracle called cakePHP so i
am pretty green to it.
i need to build a mail application, so i have followed the convention
and created:

data base description:
table of users <user_id (primary key), fname, lname>.
table of mails <mail_id(primary key), from (foreign key to user_id),
to (foreign key to user_id), content, opened>

my questions:
1) according to the convention, a foreign key should be called related
table+'_id'. how should i call the columns if there are two foreign
keys that relate to the same table. like from and to in the mails
table.

2) i would like to do an inner JOIN the between the two table.
something like
SELECT user_id, mail_id
FROM users
INNER JOIN mails
ON users.user_id =mails.to AND mails.opened=false.

but i have no clue how to do it.

please advise, thanks


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: