Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
I have never had a php class and do not write code for a living, so any suggestions on making this "better" or "correct" are greatly appreciated...so thanks for the heads up PhotoPost.

I have changed the three queries you are talking about to read as follows - they 'work' on my forums and are now counted and timed. Is there any better optimization that can be done on the below queries?

[]// ------------------------------
// Private Message Enhancement Start

// ---------------------------
// Grab total private messages
$query = "
SELECT COUNT(*)
FROM {$config['tbprefix']}Messages AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.M_Uid = '{$user['U_Number']}'
AND t1.M_Sender = t2.U_Number
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($pmtotal) = $dbh -> fetch_array($sth);

// ---------------------------------
// Grab total saved private messages
$query = "
SELECT COUNT(*)
FROM {$config['tbprefix']}Messages AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.M_Uid = '{$user['U_Number']}'
AND t1.M_Sender = t2.U_Number
AND t1.M_Status IN ('S', 'Y')
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($pmsaved) = $dbh -> fetch_array($sth);

// ---------------------------------
// Grab total sent private messages
$query = "
SELECT COUNT(*)
FROM {$config['tbprefix']}Messages AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.M_Uid = '{$user['U_Number']}'
AND t1.M_Sender = t2.U_Number
AND t1.M_Status = 'X'
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($pmsent) = $dbh -> fetch_array($sth);

$pmrec = $pmtotal - $pmsaved - $pmsent;
$max_pm = $config['total_pm'];
$p_pm = (($pmtotal/$config['total_pm']) * 100);

// ----------------------------
// Private Message Enhancement End[/]
Any way you could test this again to see if it fixes the query timing issue? My forums only have 700+ members and do not get regularly hammered...

Sponsored Links
Entire Thread
Subject Posted By Posted
Final-[6.5] Private Message Enhancement 1.0 Medar 09/24/2004 10:12 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 09/24/2004 10:13 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Zackary 09/25/2004 1:10 AM
Re: Beta-[6.5] Private Message Enhancement 1.0 DrChaos 09/25/2004 5:05 AM
Re: Beta-[6.5] Private Message Enhancement 1.0 Anno 09/25/2004 10:49 AM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 09/26/2004 7:29 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 PhotoPost 09/27/2004 3:12 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 09/27/2004 7:45 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 PhotoPost 09/27/2004 10:22 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 09/27/2004 10:43 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 DrChaos 09/28/2004 1:41 AM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 09/28/2004 3:54 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 PhotoPost 10/28/2004 3:36 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 10/28/2004 7:04 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 PhotoPost 10/28/2004 9:18 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 10/28/2004 9:27 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 Gregori 11/07/2004 5:10 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 AKD96 11/08/2004 2:01 PM
Re: Beta-[6.5] Private Message Enhancement 1.0 ZealotOnAStick_dup1 02/22/2005 2:46 AM
Re: Beta-[6.5] Private Message Enhancement 1.0 Medar 02/22/2005 10:34 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Bill B
Bill B
Issaquah, WA
Posts: 87
Joined: December 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)