Log in

View Full Version : Converting code to 3.5


Snake
08-02-2005, 06:17 PM
Hey guys, I am using the following code for one of my custom hack so I would like it converted to 3.5 please. The current code is for 3.0 so it will not work on 3.5, according to Jake.

// GET NUMBER OF NEW POSTS
$newposts = $DB_site->query_first("SELECT count(*) AS count FROM " . TABLE_PREFIX . "post WHERE dateline > '$bbuserinfo[lastvisit]'");

// DETERMINE IF "POSTS" IS SINGULAR OR PLURAL
if ($newposts[count] == 1)
{
$newposts[plural] = "";
}
else
{
$newposts[plural] = "s";
}

// GET NUMBER OF NEW THREADS
$newthreads = $DB_site->query_first("SELECT count(*) AS count FROM " . TABLE_PREFIX . "thread WHERE dateline > '$bbuserinfo[lastvisit]'");

// DETERMINE IF "THREADS" IS SINGULAR OR PLURAL
if ($newthreads[count] == 1)
{
$newthreads[plural] = "";
}
else
{
$newthreads[plural] = "s";
}

$getnews = $DB_site->query_first("SELECT threadid, title FROM ".TABLE_PREFIX."thread WHERE forumid=2 ORDER BY lastpost DESC LIMIT 1");

Andreas
08-02-2005, 06:23 PM
// GET NUMBER OF NEW POSTS
$newposts = $db->query_first("SELECT count(*) AS count FROM " . TABLE_PREFIX . "post WHERE dateline > " . $vbulletin->userinfo['lastvisit']);

// DETERMINE IF "POSTS" IS SINGULAR OR PLURAL
if ($newposts['count'] == 1)
{
$newposts[plural] = "";
}
else
{
$newposts[plural] = "s";
}

// GET NUMBER OF NEW THREADS
$newthreads = $db->query_first("SELECT count(*) AS count FROM " . TABLE_PREFIX . "thread WHERE dateline > " . $vbulletin->userinfo['lastvisit']);

// DETERMINE IF "THREADS" IS SINGULAR OR PLURAL
if ($newthreads[count] == 1)
{
$newthreads[plural] = "";
}
else
{
$newthreads[plural] = "s";
}

$getnews = $db->query_first("SELECT threadid, title FROM ".TABLE_PREFIX."thread WHERE forumid=2 ORDER BY lastpost DESC LIMIT 1");


... but you could have easily done this yourself by looking at Brads list of changed Varnames ;)

Snake
08-02-2005, 06:29 PM
Hehe you're right but I'm a lazy type guy. :P Thanks anyways.