summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorBlueRaja <BlueRaja.admin@gmail.com>2013-06-09 01:03:03 -0500
committerBlueRaja <BlueRaja.admin@gmail.com>2013-06-09 01:03:03 -0500
commit9c20000fb8871437dafb41ec830afbf56a746a57 (patch)
tree713e39b607c4ca474cd703ae9e62fca4226c7d45 /includes
parent3a65ace8a32fa2c584adee4e75a0eccc9ee37208 (diff)
downloadpathery-9c20000fb8871437dafb41ec830afbf56a746a57.tar.xz
Attempting to remove the multiple calls to getChat(); however, I seem to have broken chat...Messing_with_chat
Diffstat (limited to 'includes')
-rw-r--r--includes/chats.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/includes/chats.php b/includes/chats.php
index 7db4c58..f55ce35 100644
--- a/includes/chats.php
+++ b/includes/chats.php
@@ -44,12 +44,17 @@ function addChat($userID, $message) {
$ID = $stmt->insert_id;
$stmt->close();
+
+ //Turnicate messages.
+ $deleteFromID = $ID - CHAT_ROWS_TO_KEEP;
+ $mysqli->query("DELETE FROM `chat` WHERE `ID` < $deleteFromID");
+ $mysqli->close();
+
return $ID;
}
function getChat($startID = 0) {
global $mysqli;
- $array = array();
if (!is_numeric($startID)) return false;
@@ -68,7 +73,7 @@ function getChat($startID = 0) {
LEFT JOIN `users`
ON chat.userID = users.ID
WHERE chat.ID > '$startID'
- ORDER BY chat.ID ASC
+ ORDER BY chat.dateSent ASC, chat.ID ASC
");
$array = array();
if ($res->num_rows == 0) {
@@ -77,16 +82,11 @@ function getChat($startID = 0) {
}
while ($response = $res->fetch_assoc()) {
$array[] = $response;
- $lastID = $response['ID'];
}
$res->close();
+ $mysqli->close();
if (count($array) < 1) return false;
-
- //Turnicate messages.
- $deleteFromID = $lastID - CHAT_ROWS_TO_KEEP;
- $mysqli->query("DELETE FROM `chat` WHERE `ID` < $deleteFromID");
- $mysqli->close();
return $array;
}