|
From: Bart v. B. <ba...@us...> - 2001-12-15 16:15:48
|
Update of /cvsroot/phpbb/phpBB2
In directory usw-pr-cvs1:/tmp/cvs-serv31565
Modified Files:
search.php
Log Message:
Sped up searching for posts from a specific user a lot
Index: search.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/search.php,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -r1.45 -r1.46
*** search.php 2001/12/14 02:39:44 1.45
--- search.php 2001/12/15 16:15:45 1.46
***************
*** 288,297 ****
{
$query_author = str_replace("*", "%", trim($query_author));
! $sql = "SELECT p.post_id
! FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
! WHERE u.username LIKE '$query_author'
! AND p.poster_id = u.user_id
! ORDER BY p.post_time DESC";
}
$result = $db->sql_query($sql);
--- 288,318 ----
{
$query_author = str_replace("*", "%", trim($query_author));
+
+ $sql = "SELECT user_id
+ FROM ".USERS_TABLE."
+ WHERE username LIKE '$query_author'";
+ $result = $db->sql_query($sql);
+ if( !$result )
+ {
+ message_die(GENERAL_ERROR, "Couldn't obtain list of matching users (searching for: $query_author)", "", __LINE__, __FILE__, $sql);
+ }
+ if( $db->sql_numrows($result) == 0 )
+ {
+ message_die(GENERAL_MESSAGE, $lang['No_search_match']);
+ }
+
+ while( $row = $db->sql_fetchrow($result) )
+ {
+ if( $matching_userids != "" )
+ {
+ $matching_userids .= ", ";
+ }
+ $matching_userids .= $row['user_id'];
+ }
! $sql = "SELECT post_id
! FROM " . POSTS_TABLE . "
! WHERE poster_id IN ($matching_userids)
! ORDER BY post_time DESC";
}
$result = $db->sql_query($sql);
|