'Unread Posts' question
Moderator: General Moderators
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
'Unread Posts' question
Hi,
You guys know the 'unread posts' feature in IPB, SMF, etc... so the board remembers which threads you have not read. I am asking how to do this? I know couple of methods to do this but what could be the fastest one?
If I have 5000 topics and 5000 members... you understand that simply making rows of each new unread messages would make my dabatase big...
Help thanks!
You guys know the 'unread posts' feature in IPB, SMF, etc... so the board remembers which threads you have not read. I am asking how to do this? I know couple of methods to do this but what could be the fastest one?
If I have 5000 topics and 5000 members... you understand that simply making rows of each new unread messages would make my dabatase big...
Help thanks!
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
-
timclaason
- Forum Commoner
- Posts: 77
- Joined: Tue Dec 16, 2003 9:06 am
- Location: WI
Quickest way
$_SESSION or cookies would work well, I think. It wouldn't be explicitly permanent the way a db entry is, but it would be reasonably close to achieving what you're looking for. Then that way, it's more client-side.
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: Quickest way
Thanks for the idea, but I think I'll stick around with the databases as they are used to store data permanently.timclaason wrote:$_SESSION or cookies would work well, I think. It wouldn't be explicitly permanent the way a db entry is, but it would be reasonably close to achieving what you're looking for. Then that way, it's more client-side.
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Any help?
I found this from my friend's ipb script:
I found this from my friend's ipb script:
Code: Select all
function get_new_posts()
{
if ( ! $this->ipsclass->member['id'] and ! $this->ipsclass->input['active'] )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
}
//-----------------------------------------
// Do we have flood control enabled?
//-----------------------------------------
if ($this->ipsclass->member['g_search_flood'] > 0)
{
$flood_time = time() - $this->ipsclass->member['g_search_flood'];
// Get any old search results..
$this->ipsclass->DB->simple_construct( array( 'select' => 'id',
'from' => 'search_results',
'where' => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );
$this->ipsclass->DB->simple_exec();
if ( $this->ipsclass->DB->get_num_rows() )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );
}
}
$last_time = $this->ipsclass->member['last_visit'];
if ( $this->ipsclass->member['members_markers']['board'] > $last_time )
{
$last_time = $this->ipsclass->member['members_markers']['board'];
}
//-----------------------------------------
// Are we getting 'active topics'?
//-----------------------------------------
if ( $this->ipsclass->input['active'] )
{
if ( $this->ipsclass->input['lastdate'] )
{
$last_time = time() - intval($this->ipsclass->input['lastdate']);
}
else
{
$last_time = time() - 86400;
}
}
$this->ipsclass->input['forums'] = 'all';
$this->ipsclass->input['nav'] = 'lv';
$forums = $this->get_searchable_forums();
//-----------------------------------------
// Do we have any forums to search in?
//-----------------------------------------
if ($forums == "")
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
}
//-----------------------------------------
// Get the topic ID's to serialize and store into
// the database
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'count(*) as count', 'from' => 'topics', 'where' => "approved=1 AND state != 'link' AND forum_id IN($forums) AND last_post > '".$last_time."'" ) );
$this->ipsclass->DB->simple_exec();
$row = $this->ipsclass->DB->fetch_row();
$results = intval($row['count']);
//-----------------------------------------
// Do we have any results?
//-----------------------------------------
if ( ! $results )
{
//$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
}
//-----------------------------------------
// Cache query
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 't.*, t.title as topic_title',
'from' => 'topics t',
'where' => "t.approved=1 AND t.state != 'link' AND t.forum_id IN($forums) AND t.last_post > {$last_time}",
'order' => "t.last_post DESC" ) );
$query_to_cache = $this->ipsclass->DB->cur_query;
$this->ipsclass->DB->flush_query();
//-----------------------------------------
// If we are still here, store the data into the database...
//-----------------------------------------
$unique_id = md5(uniqid(microtime(),1));
$this->ipsclass->DB->do_insert( 'search_results', array (
'id' => $unique_id,
'search_date' => time(),
'post_max' => $results,
'sort_key' => $this->sort_key,
'sort_order' => $this->sort_order,
'member_id' => $this->ipsclass->member['id'],
'ip_address' => $this->ipsclass->input['IP_ADDRESS'],
'query_cache' => $query_to_cache
) );
$this->ipsclass->boink_it( $this->ipsclass->base_url."act=Search&nav=lv&CODE=show&searchid=$unique_id&search_in=topics&result_type=topics&lastdate={$this->ipsclass->input['lastdate']}" );
}