diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 09:40:20 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 09:40:20 -0600 |
commit | 7c3f2e348c015ea93563d866f89ec8cea9159ea0 (patch) | |
tree | b7b6b18cf9087f42300f621d15101628a8d214e4 /includes/functions_insert.php | |
parent | 6c9369ad85f2fb3dc61234b54db7e7079cdc0c4e (diff) |
Refactoring part 2
Starting to move some functionality such as the session and database connection into singleton classes to manage them. Functions for modifying posts and threads are being put in one place as well.
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); -} |