Jenta
05-04-2005, 04:02 PM
Am I doing this the most efficient and proper way? I don't trust myself much :nervous:
It works but perhaps it's noobish? Can u tell me how to make it more correct?
I'm mostly referring to stuff like changing some things to OR, AND, ELSE and combing it into one statement or whatever.
Will doing so make it parse faster and more effieciently?
// question 1
if (!defined('IN_PORTAL_AREA')) {
// question 2
if (THIS_SCRIPT == 'index')
{
// do something
$lifetime_posts = $DB_site->query_first("SELECT post.postid
FROM " . TABLE_PREFIX . "post AS post
ORDER BY post.postid DESC
LIMIT 1");
$lifetime_threads = $DB_site->query_first("SELECT thread.threadid
FROM " . TABLE_PREFIX . "thread AS thread
ORDER BY thread.threadid DESC
LIMIT 1");
}
// question 3
if (THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'forumdisplay')
{
// do something
$forumcounts= $DB_site->query("SELECT forumid, replycount, threadcount
FROM " . TABLE_PREFIX . "forum
");
while ($forumcount = $DB_site->fetch_array($forumcounts))
{
$forumreply[$forumcount[forumid]] = $forumcount[replycount];
$forumthread[$forumcount[forumid]] = $forumcount[threadcount];
}
}
// question 4
if ($bbuserinfo['userid'] != 1) {
// question 5
if (THIS_SCRIPT == 'adv_index')
{
// do something
include("./forums/statistic_counter.php");
}
// question 6
if (THIS_SCRIPT == 'index')
{
// do something
include("./statistic_counter.php");
}
}
// question 7
if (defined('IN_PORTAL_AREA')) {
// do something
require_once('./global.php');
}
thanks!
It works but perhaps it's noobish? Can u tell me how to make it more correct?
I'm mostly referring to stuff like changing some things to OR, AND, ELSE and combing it into one statement or whatever.
Will doing so make it parse faster and more effieciently?
// question 1
if (!defined('IN_PORTAL_AREA')) {
// question 2
if (THIS_SCRIPT == 'index')
{
// do something
$lifetime_posts = $DB_site->query_first("SELECT post.postid
FROM " . TABLE_PREFIX . "post AS post
ORDER BY post.postid DESC
LIMIT 1");
$lifetime_threads = $DB_site->query_first("SELECT thread.threadid
FROM " . TABLE_PREFIX . "thread AS thread
ORDER BY thread.threadid DESC
LIMIT 1");
}
// question 3
if (THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'forumdisplay')
{
// do something
$forumcounts= $DB_site->query("SELECT forumid, replycount, threadcount
FROM " . TABLE_PREFIX . "forum
");
while ($forumcount = $DB_site->fetch_array($forumcounts))
{
$forumreply[$forumcount[forumid]] = $forumcount[replycount];
$forumthread[$forumcount[forumid]] = $forumcount[threadcount];
}
}
// question 4
if ($bbuserinfo['userid'] != 1) {
// question 5
if (THIS_SCRIPT == 'adv_index')
{
// do something
include("./forums/statistic_counter.php");
}
// question 6
if (THIS_SCRIPT == 'index')
{
// do something
include("./statistic_counter.php");
}
}
// question 7
if (defined('IN_PORTAL_AREA')) {
// do something
require_once('./global.php');
}
thanks!