cvs: php-master-web /manage users.php

From: Date: Mon, 06 Jul 2009 18:45:46 +0000
Subject: cvs: php-master-web /manage users.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-5254@lists.php.net to get a copy of this message
johannes Mon Jul 6 18:45:46 2009 UTC Modified files: /php-master-web/manage users.php Log: - Improve performance of notes search by splitting join into two queries - Fix prev/next links with notes search http://cvs.php.net/viewvc.cgi/php-master-web/manage/users.php?r1=1.58&r2=1.59&diff_format=u Index: php-master-web/manage/users.php diff -u php-master-web/manage/users.php:1.58 php-master-web/manage/users.php:1.59 --- php-master-web/manage/users.php:1.58 Fri Jul 3 19:40:31 2009 +++ php-master-web/manage/users.php Mon Jul 6 18:45:46 2009 @@ -324,11 +324,21 @@ $query = "SELECT DISTINCT SQL_CALC_FOUND_ROWS users.userid,cvsaccess,username,name,email FROM users "; if ($search) { - $where = "WHERE (MATCH(name,email,username) AGAINST ('$search') OR username = '$search') "; + $query .= "WHERE (MATCH(name,email,username) AGAINST ('$search') OR username = '$search') "; + if ($searchnotes) { - $query .= " LEFT JOIN users_note USING(userid) $where OR MATCH(note) AGAINST ('$search') "; - } else { - $query .= $where; + $in = ''; + $notes_query = "SELECT userid FROM users_note WHERE MATCH(note) AGAINST ('$search')"; + $res = db_query($notes_query); + while ($row = mysql_fetch_array($res)) { + if ($in) { + $in .= ', '; + } + $in .= $row[0]; + } + if ($in) { + $query .= " OR userid IN ($in) "; + } } } else { $query .= ' WHERE 1=1 '; @@ -356,7 +366,7 @@ "max" => $max, "full" => $full, "unapproved" => $unapproved, - "searchnotes" => (int)$search_notes, + "searchnotes" => (int)$searchnotes, ); show_prev_next($begin,mysql_num_rows($res),$max,$total,$extra);

« previous php.webmaster (#5254) next »