vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Can anyone tell me... (https://vborg.vbsupport.ru/showthread.php?t=3028)

09-11-2000 04:17 AM

Quote:

Originally posted by Michael
But threadcount is incremented everytime something is posted, but if there was an error in MySQL and some information was deleted then threadcount would be inaccurate. If you wanted to delete a post through PhpMyAdmin then threadcount would be wrong.

Using a field that is incremented to keep count isn't very accurate.

Indeed, I'm not quite sure why no one is using this:

Code:

<?php
require( "forum/admin/config.php3" );
$db = mysql_connect( $servername, $dbusername, $dbpassword );
mysql_select_db( $dbname );
$query=mysql_query( "SELECT COUNT( * ) AS totalthreads FROM thread WHERE forumid = $forumid" );
$row = mysql_fetch_array( $query );
$totalthreads = $row[ totalthreads ];
echo "$totalthreads total threads";

?>

It's simple.

Easy.

And works.

[Edited by mrogish on 09-11-2000 at 01:22 AM]

09-11-2000 06:33 AM

That way works as well - one of the books I have says that mysql_num_rows function isa better way, but what you have is better then using the threadcount field.

09-11-2000 10:33 AM

lol!

09-11-2000 11:28 AM

?

09-12-2000 01:16 AM

Quote:

Originally posted by Michael
That way works as well - one of the books I have says that mysql_num_rows function isa better way, but what you have is better then using the threadcount field.
The only reason why I would use count( ) is that:

1. count is a built in SQL function -- so it's far more efficent than selecting everything in the table.
2. Once you get a result you directly access the array $result[ somevar ]; rather than executing another function (mysql_num_rows( )) -- this would shave off some overhead on PHP's account I would believe.
3. That's what the count( ) function is supposed to do! :)
4. There is no number 4!

But, all of the methods work, it's up to whomever wanted it in the first place to decide! :)

09-12-2000 02:05 AM

Thanks guys... :)

09-12-2000 03:45 AM

I guess your right, cause SQL functions are faster then PHP functions.


All times are GMT. The time now is 05:37 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01901 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete