diff options
Diffstat (limited to 'includes/functions_insert.php')
-rw-r--r-- | includes/functions_insert.php | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/includes/functions_insert.php b/includes/functions_insert.php deleted file mode 100644 index 4f60701..0000000 --- a/includes/functions_insert.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -// This file may be replaced by a MVC controller later on - -function insert_thread($dbc, $thread_subject, $thread_cat, $thread_author) { - $sql = "INSERT INTO threads(thread_subject, thread_date_created, thread_date_lastpost, thread_category, thread_author) VALUES (?, CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), ?, ?);"; - $stmt = mysqli_stmt_init($dbc); - - if (!mysqli_stmt_prepare($stmt, $sql)) { - die('Could not create thread due to internal error: ' . mysqli_error($dbc)); - } - - mysqli_stmt_bind_param($stmt, "sii", $thread_subject, $thread_cat, $thread_author); - mysqli_stmt_execute($stmt); - mysqli_stmt_close($stmt); -} - -function insert_post($dbc, $post_content, $post_thread, $post_author, $post_category) { - $sql = "INSERT INTO posts(post_content, post_date_created, post_thread, post_author) VALUES (?, CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), ?, ?);"; - $stmt = mysqli_stmt_init($dbc); - - if (!mysqli_stmt_prepare($stmt, $sql)) { - die('Could not create post due to internal error: ' . mysqli_error($dbc)); - } - - mysqli_stmt_bind_param($stmt, "sii", $post_content, $post_thread, $post_author); - mysqli_stmt_execute($stmt); - mysqli_stmt_close($stmt); - - $sql = "UPDATE categories SET `cat_post_count` = `cat_post_count` + '1' WHERE cat_id = " . $post_category . ";"; - mysqli_query($dbc, $sql); - - $sql = "UPDATE threads SET thread_date_lastpost = CONVERT_TZ(NOW(), 'SYSTEM', '+00:00') WHERE thread_id = " . $post_thread . ";"; - mysqli_query($dbc, $sql); -} |