vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Help with porting over latest postid/threadid (https://vborg.vbsupport.ru/showthread.php?t=97854)

freakyshiat 10-08-2005 05:01 AM

Help with porting over latest postid/threadid
 
I need to port over the latest threadid/postid on index page from 3.0.x to 3.5.x. The code below worked fine in 3.0.x, can someone help me port it to 3.5.x? I can via paypal, please pm me.

Code:

$newestthreadidq = $DB_site->query("
                                SELECT threadid
                                FROM thread
                                ORDER BY threadid DESC
                                LIMIT 1
                                ");
$newestthreadid = $DB_site->fetch_array($newestthreadidq);
$newestpostidq = $DB_site->query("
                                SELECT postid
                                FROM post
                                ORDER BY postid DESC
                                LIMIT 1
                            ");
$newestpostid = $DB_site->fetch_array($newestpostidq);
$formattedthreadid = number_format($newestthreadid[threadid]);
$formattedpostid = number_format($newestpostid[postid]);


Colin F 10-08-2005 08:34 AM

If you just want that code to work with 3.5, use this:

Code:

$newestthreadidq = $db->query_read("
                                SELECT threadid
                                FROM thread
                                ORDER BY threadid DESC
                                LIMIT 1
                                ");
$newestthreadid = $db->fetch_array($newestthreadidq);
$newestpostidq = $db->query_read("
                                SELECT postid
                                FROM post
                                ORDER BY postid DESC
                                LIMIT 1
                            ");
$newestpostid = $db->fetch_array($newestpostidq);
$formattedthreadid = number_format($newestthreadid[threadid]);
$formattedpostid = number_format($newestpostid[postid]);


Andreas 10-08-2005 10:24 AM

Better
PHP Code:

$newestids $db->query_first("SELECT MAX(threadid) AS threadid, MAX(postid) AS postid FROM " TABLE_PREFIX "post");
$formattedthreadid number_format($newestids['threadid']);
$formattedpostid number_format($newestids['postid']); 

1 Query instead of 2, no sorting, no table or index scan :)

freakyshiat 10-08-2005 06:26 PM

woohoo!!! thank you all :)


All times are GMT. The time now is 01:50 PM.

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.00999 seconds
  • Memory Usage 1,721KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete