private static function insert(Message $model) { $db = DatabaseData::getInstance(\RedDevil\Config\DatabaseConfig::DB_INSTANCE); $query = "INSERT INTO messages (SenderId,RecipientId,Content,CreatedOn) VALUES (:SenderId, :RecipientId, :Content, :CreatedOn);"; $result = $db->prepare($query); $result->execute([':SenderId' => $model->getSenderId(), ':RecipientId' => $model->getRecipientId(), ':Content' => $model->getContent(), ':CreatedOn' => $model->getCreatedOn()]); $model->setId($db->lastInsertId()); }
function __construct(Message $message) { $this->id = $message->getId(); $this->content = $message->getContent(); $this->createdOn = $message->getCreatedOn(); }