I want to make private messages in my site. I want that user can delete received or sent messages. For it I need two tables one for send message and one for receive....Is it to possible that when user send messages, it automatically add fro two tables? or it is better to make some relations with tables? or maybe exist better solution?
I think you need just one table:
Message:
columns:
from: integer
to: integer
header: string(100)
body: blob
show_in_outcoming:
type: boolean
default: true
show_in_incoming:
type: boolean
default: true
is_read:
type: boolean
default: false
UserFrom:
class: sfGuardUser
local: from
foreign: id
foreignType: one
type: one
UserTo:
class: sfGuardUser
local: to
foreign: id
foreignType: one
type: one
where
If the user who sends the message want to delete it, we simply hide it (not delete from the DB) - set show_in_outcoming to false. If the user who received the message want to delete it, we hide it too - set show_in_incoming to false. This approach allows us to recover the "hidden" messages (or remove them altogether)