ryan1918dotcom wrote:wow that's crazy.
Not to mention expensive!
ryan1918dotcom wrote:wow that's crazy.
dcz wrote:What would be interesting to know is what is gaiaonline server setup ?
Single server, cluestered ?
Separated sql, with slaves ?
Which db type ?
What is your session trick (30 000 at a time, must be hard to deal with sometimes) ?
And since obviously you tweaked it a lot, did you implement other things than the one demonstarted here?
This may have olready been said somewhere, but I am wondering.
By the way, bravo for gaia, hudge, and still fast.
Thanks to you, nobody can really say phpbb is not a working script (even though you must have changed a lot of things).
++
// Pages
$total_pages = ceil($total_replies/$board_config['posts_per_page']);
$on_page = floor($start / $board_config['posts_per_page']) + 1;
if ($start > 100 && ($total_replies / 2) < $start) {
$reverse = TRUE;
$last_page_posts = $total_replies - ($board_config['posts_per_page'] * ($total_pages - 1));
}
// Reverse & Post Id's
$p_array = array();
if (isset($reverse)) {
$limit_string = ($total_pages == $on_page) ? $last_page_posts : ($last_page_posts + ($total_pages - $on_page - 1) * $board_config['posts_per_page'] ).','. $board_config['posts_per_page'];
$sql = "SELECT p.post_id FROM " . POSTS_TABLE . " p USE INDEX(topic_n_id) WHERE p.topic_id = $topic_id $limit_posts_time ORDER BY p.post_id DESC LIMIT $limit_string";
} else {
$sql = "SELECT p.post_id FROM " . POSTS_TABLE . " p WHERE p.topic_id = $topic_id $limit_posts_time LIMIT $start, " . $board_config['posts_per_page'];
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post index information.", '', __LINE__, __FILE__, $sql);
}
$post_index = '';
while ($row = $db->sql_fetchrow($result))
{
$post_index .= (($post_index != '') ? ', ' : '') . intval($row['post_id']);
}
$db->sql_freeresult($result);
// Pull the data
$sql = "SELECT pt.post_sub_title, u.username, u.user_id, u.user_posts, u.user_from, u.user_firstname, u.user_ebayname, u.user_car, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_gender, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.post_id in ($post_index)
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time $post_time_order";da_badtz_one wrote:There seems to be a problem with this coding.
- Code: Select all
$p_array = array();
$sql = "SELECT p.post_id FROM " . POSTS_TABLE . " p WHERE p.topic_id = $topic_id $limit_posts_time LIMIT $start, " . $board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post index information.", '', __LINE__, __FILE__, $sql);
}
while (list($p_id) = $db->sql_fetchrow($result)) {
$p_array[] = $p_id;
}
$post_index = implode(",",$p_array);
The problem comes in when the large query of
- Code: Select all
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_warnings, u.user_level, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid,t.topic_poster
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.post_id in ($post_index)
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time $post_time_order";
only gets ,,,,,, from $post_index
So I get this error:
- Code: Select all
Could not obtain post/user information.
DEBUG MODE
SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,,,,) AND pt.post_id = p.post_id AND u.user_id = p.poster_id ' at line 3
SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_warnings, u.user_level, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid,t.topic_poster FROM phpbb_posts p, phpbb_users u, phpbb_posts_text pt WHERE p.post_id in (,,,,,,,,) AND pt.post_id = p.post_id AND u.user_id = p.poster_id ORDER BY p.post_time ASC
Line : 507
File : viewtopic.php
Could someone post the right coding to get a correct $post_index?
$p_array = array();
$sql = "SELECT p.post_id
FROM " . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
$limit_posts_time
ORDER BY p.post_time $post_time_order
LIMIT $start, " . $board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post index information.", '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result))
{
$p_array[] = $row['post_id'];
}
$post_index = implode(",",$p_array); 
Dog Cow wrote:If you have a forum that only uses one style, you can hard code your forum to that style, thus eliminating at least two queries.
The function and queries to look for are in functions.php and the function is called setup_style
function setup_style($style)
{
global $db, $board_config, $template, $images, $phpbb_root_path;
$sql = "SELECT *
FROM " . THEMES_TABLE . "
WHERE themes_id = $style";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not query database for theme info');
}
if ( !($row = $db->sql_fetchrow($result)) )
{
// We are trying to setup a style which does not exist in the database
// Try to fallback to the board default (if the user had a custom style)
// and then any users using this style to the default if it succeeds
if ( $style != $board_config['default_style'])
{
$sql = 'SELECT *
FROM ' . THEMES_TABLE . '
WHERE themes_id = ' . $board_config['default_style'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not query database for theme info');
}
if ( $row = $db->sql_fetchrow($result) )
{
$db->sql_freeresult($result);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_style = ' . $board_config['default_style'] . "
WHERE user_style = $style";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not update user theme info');
}
}
else
{
message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
}
}
else
{
message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
}
}
$template_path = 'templates/' ;
$template_name = $row['template_name'] ;
function setup_style($style)
{
global $db, $board_config, $template, $images, $phpbb_root_path, $phpEx;
/*
$sql = "SELECT *
FROM " . THEMES_TABLE . "
WHERE themes_id = $style";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not query database for theme info');
}
if ( !($row = $db->sql_fetchrow($result)) )
{
// We are trying to setup a style which does not exist in the database
// Try to fallback to the board default (if the user had a custom style)
// and then any users using this style to the default if it succeeds
if ( $style != $board_config['default_style'])
{
$sql = 'SELECT *
FROM ' . THEMES_TABLE . '
WHERE themes_id = ' . $board_config['default_style'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not query database for theme info');
}
if ( $row = $db->sql_fetchrow($result) )
{
$db->sql_freeresult($result);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_style = ' . $board_config['default_style'] . "
WHERE user_style = $style";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not update user theme info');
}
}
else
{
message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
}
}
else
{
message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
}
}
$db->sql_freeresult($result);
*/
// Start caching
$row = array();
include($phpbb_root_path . 'cache/theme.' .$phpEx);
if (sizeof($row) == 0)
{
$sql = "SELECT SQL_CACHE *
FROM " . THEMES_TABLE . "
WHERE themes_id = $style";
if( !$result = $db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Could not query database for theme info');
}
$file_data = '<? ' . '$row = ' . format_array($db->sql_fetchrow($result)) . ' ?>';
$db->sql_freeresult($result);
$handle = fopen($phpbb_root_path . 'cache/theme.'.$phpEx, 'w');
@flock($handle, LOCK_EX);
fwrite($handle, $file_data);
@flock($handle, LOCK_UN);
fclose($handle);
include($phpbb_root_path . 'cache/theme.' .$phpEx);
}
// End caching
$template_path = 'templates/' ;
$template_name = $row['template_name'] ;
cache/theme.'.$phpEx
Users browsing this forum: No registered users and 1 guest