Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Public and Private Messages /** * The registry object */ private $registry; /** * ID of the message */ private $id=0; /** * ID of the sender */ private $sender; /** * Name of the sender */ private $senderName; /** * ID of the recipient */ private $recipient; /** * Name of the recipient */ private $recipientName; /** * Subject of the message */ private $subject; /** * When the message was sent (TIMESTAMP) */ private $sent; /** * User readable, friendly format of the time the message was sent */ [ 212 ] Download from www.eBookTM.com Chapter 7 private $sentFriendlyTime; /**. | Public and Private Messages The registry object private registry ID of the message private id 0 ID of the sender private sender Name of the sender private senderName ID of the recipient private recipient Name of the recipient private recipientName Subject of the message private subject When the message was sent TIMESTAMP private sent User readable friendly format of the time the message was sent ------------------------------ 212 ----------------------------------- Download from www.eBookTM.com Chapter 7 private sentFriendlyTime Has the message been read private read 0 The message content itself private message The constructor takes the registry and ID of the message as parameters if the ID has been defined then it queries the database and sets the class variables. The database query here also formats a copy of the date into a friendlier format and looks up the names of the sender and recipient of the message Message constructor @param Registry registry the registry object @param int id the ID of the message return void public function __construct Registry registry id 0 this- registry registry this- id id if this- id 0 sql SELECT m. DATE_FORMAT m.sent D M Y as sent_friendly psender.name as sender_name precipient.name as recipient_name FROM messages m profile psender profile precipient WHERE precipient.user_id m.recipient AND psender.user_id m.sender AND m.ID . this- id this- registry- getObject db - executeQuery sql if this- registry- getObject db - numRows 0 data this- registry- getObject db - getRows this- sender data sender this- recipient data recipient this- sent data sent this- read data read this- subject data subject this- message data message ----------------------------------- 213 ----------------------------------- Download from www.eBookTM.com Public and Private Messages this- sentFriendlyTime data sent_friendly this- senderName data sender_name this- recipientName data recipient_name else this- id 0 Next we have setter methods for most of the class .