diff options
author | Camil Staps | 2016-07-31 09:40:25 +0200 |
---|---|---|
committer | Camil Staps | 2016-07-31 09:40:25 +0200 |
commit | 1ec8d12a7b125d41ecb723c5d83f2afef95408e9 (patch) | |
tree | 4d103ccbab48d2217e1ae13d37c229e4060e9184 /classes/BusinessAdmin.php | |
parent | Give new files a key (diff) |
0.5.2 emails
Diffstat (limited to 'classes/BusinessAdmin.php')
-rw-r--r-- | classes/BusinessAdmin.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/classes/BusinessAdmin.php b/classes/BusinessAdmin.php index 7c3c76c..83fa4b3 100644 --- a/classes/BusinessAdmin.php +++ b/classes/BusinessAdmin.php @@ -407,6 +407,28 @@ class BusinessAdmin { } /** + * Create a new mail + * + * @param PDO $pdo The database connection + * @param int $contactId The contactId for the new mail + * @param int $offerId The offerId for the new mail + * @param string $subject + * + * @throws PDOException If something went wrong with the database + * + * @return Mail|bool A new instance of the Mail class, or false on failure + */ + public static function createMail($pdo, $contactId, $offerId, $subject) { + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."mail` (`contactId`, `offerId`, `subject`) VALUES (?,?,?)"); + $stmt->execute([$contactId, $offerId, $subject]); + if ($stmt->rowCount() == 1) { + return new Mail($pdo, $pdo->lastInsertId()); + } else { + return false; + } + } + + /** * Format a date nicely * * @todo implement $relatively = true |