TBDev Forum
Programming board
Main Page Forum Rules Privacy Policy Members Contact Us
Welcome Guest (Login | Register)
TBDev Forum TBDev.net - Mods & hacks Mods Complete & working Optimize Inbox
Page 1 2

Optimize Inbox

2006-07-05 18:16:00
Group: Member
Posts: 25
Topics participated: 15
Topics started: 8
First post: 2006-03-04 10:39:00
Last post: 2006-10-04 09:06:00
There's a bad query in loop in the inbox.php which means that if you have 20 pms, then you'll get 20+ queries each time you check your inbox. I suggest to remove this query by storing sender's and receiver's usernames in the 'messages' table.
Here's how it could be done:

Modify your 'messages' table:

ALTER TABLE `messages` ADD `sender_username` VARCHAR( 250 ) DEFAULT 'System' NOT NULL;
ALTER TABLE `messages` ADD `receiver_username` VARCHAR( 250 ) NOT NULL;


Open inbox.php
find and comment these 2 lines
$res2 = mysql_query("SELECT username FROM users WHERE id=" . $arr["receiver"]) or sqlerr();
$arr2 = mysql_fetch_assoc($res2);

find

replace with

find and comment
$res2 = mysql_query("SELECT username FROM users WHERE id=" . $arr["sender"]) or sqlerr();
$arr2 = mysql_fetch_assoc($res2);

find

replace with


Open takemessage.php

find
$query = "INSERT INTO messages (sender, receiver, added, msg, poster) ".
 
2006-07-05 18:36:00
Group: Member
Posts: 510
Topics participated: 277
Topics started: 5
First post: 2006-03-13 22:18:00
Last post: 2006-10-25 20:54:00
Why not just use a JOIN in that select?
 
2006-07-05 18:38:00
Group: Member
Posts: 20
Topics participated: 10
Topics started: 2
First post: 2006-07-05 18:38:00
Last post: 2007-01-02 07:46:00
If I understand that code correctly doesn't using this mod mean that that all old messages will show wrong?
And if it does then before using this you should update messages table up to date by putting all the correct usernames to all rows...
 
2006-07-05 19:16:00
Group: Member
Posts: 25
Topics participated: 15
Topics started: 8
First post: 2006-03-04 10:39:00
Last post: 2006-10-04 09:06:00
Why not just use a JOIN in that select?

And what about user named System who sends all notifications and stuff?

If I understand that code correctly doesn't using this mod mean that that all old messages will show wrong?
And if it does then before using this you should update messages table up to date by putting all the correct usernames to all rows...


You're right, but i think pms are not so valuable, so you can just do "delete from messages" query
 
2006-07-05 19:21:00
Group: Member
Posts: 510
Topics participated: 277
Topics started: 5
First post: 2006-03-13 22:18:00
Last post: 2006-10-25 20:54:00
And what about user named System who sends all notifications and stuff?

Those would return a NULL value, and you can catch that NULL either still in your query or ue PHP for it ;)
 
2006-07-05 19:28:00
Group: Member
Posts: 25
Topics participated: 15
Topics started: 8
First post: 2006-03-04 10:39:00
Last post: 2006-10-04 09:06:00
Well, that's cause i didn't know it... Then why it's not done by default?
 
2006-07-05 19:32:00
Group: Member
Posts: 510
Topics participated: 277
Topics started: 5
First post: 2006-03-13 22:18:00
Last post: 2006-10-25 20:54:00
Then why it's not done by default?

MMysql 3.x compatibility maybe, don't know how old that code is
 
2006-07-05 19:34:00
Group: Member
Posts: 25
Topics participated: 15
Topics started: 8
First post: 2006-03-04 10:39:00
Last post: 2006-10-04 09:06:00
Will you be so kind and post your way of optimizing?
 
2006-07-05 19:44:00
Group: Member
Posts: 510
Topics participated: 277
Topics started: 5
First post: 2006-03-13 22:18:00
Last post: 2006-10-25 20:54:00
SELECT
 
2006-07-07 04:17:00
Group: Member
Posts: 461
Topics participated: 232
Topics started: 10
First post: 2006-03-21 13:50:00
Last post: 2008-12-23 18:24:00
I would prefer the query to return a NULL to the script, then it can do what it wants with the NULL, such as create 'system' that doesn't hyperlink, of a 'system' that hyperlinks to a staff PM system.
 

Similar threads

Topic Posts Last post
help optimize 7 2008-04-03 21:50:00
New INBOX modification 37 2008-07-28 13:57:00
problem with inbox 2 2007-11-04 13:44:00
New nicer inbox 26 2008-07-08 21:28:00
inbox.php 3 2007-10-28 04:05:00