From 1ec8d12a7b125d41ecb723c5d83f2afef95408e9 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 31 Jul 2016 09:40:25 +0200 Subject: 0.5.2 emails --- classes/BusinessAdmin.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'classes/BusinessAdmin.php') diff --git a/classes/BusinessAdmin.php b/classes/BusinessAdmin.php index 7c3c76c..83fa4b3 100644 --- a/classes/BusinessAdmin.php +++ b/classes/BusinessAdmin.php @@ -406,6 +406,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 * -- cgit v1.2.3