[geeklog-cvs] geeklog-1.3/public_html users.php,1.49,1.50
dhaun at geeklog.net
dhaun at geeklog.net
Thu Jan 9 14:33:04 EST 2003
- Previous message (by thread): [geeklog-cvs] geeklog-1.3/docs config.html,1.12,1.13 history,1.61,1.62 support.html,1.6,1.7
- Next message (by thread): [geeklog-cvs] A_and_A/client/testscripts AAServiceInterfaceTest.class.php,1.2,1.3 AAUserTest.class.php,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory internal.geeklog.net:/tmp/cvs-serv29830
Modified Files:
users.php
Log Message:
Two improvements building and using the list of story IDs (for the user
profile), provided by Marc von Ahn
Index: users.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/users.php,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** users.php 5 Jan 2003 21:28:08 -0000 1.49
--- users.php 9 Jan 2003 19:33:02 -0000 1.50
***************
*** 174,184 ****
$result = DB_query($sql);
$numsids = DB_numRows($result);
! $sidList = '';
for ($i = 1; $i <= $numsids; $i++) {
$S = DB_fetchArray ($result);
! $sidList .= $S['sid'];
! if ($i != $numsids) {
! $sidList .= ',';
! }
}
// add all polls the current visitor has access to
--- 174,181 ----
$result = DB_query($sql);
$numsids = DB_numRows($result);
! $sidArray = array();
for ($i = 1; $i <= $numsids; $i++) {
$S = DB_fetchArray ($result);
! $sidArray[] = $S['sid'];
}
// add all polls the current visitor has access to
***************
*** 192,211 ****
$result = DB_query($sql);
$numqids = DB_numRows($result);
! if (($numqids > 0) && !empty ($sidList)) {
! $sidList .= ',';
! }
for ($i = 1; $i <= $numqids; $i++) {
$Q = DB_fetchArray ($result);
! $sidList .= "'" . $Q['qid'] . "'";
! if ($i != $numqids) {
! $sidList .= ',';
! }
}
// then, find all comments by the user in those stories and polls
! $sql = "SELECT sid,title,pid,type,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = $user) ";
if (!empty ($sidList)) {
! $sql .= " AND (sid in ($sidList))";
}
$sql .= " ORDER BY unixdate DESC LIMIT 10";
$result = DB_query($sql);
$nrows = DB_numRows($result);
--- 189,214 ----
$result = DB_query($sql);
$numqids = DB_numRows($result);
!
for ($i = 1; $i <= $numqids; $i++) {
$Q = DB_fetchArray ($result);
! $sidArray[] = $S['sid'];
}
+
+ $sidList = implode("', '",$sidArray);
+ $sidList = "'$sidList'";
+
// then, find all comments by the user in those stories and polls
! $sql = "SELECT sid,title,pid,type,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = $user)";
!
! // SQL NOTE: Using a HAVING clause is usually faster than a where if the
! // field is part of the select
! // if (!empty ($sidList)) {
! // $sql .= " AND (sid in ($sidList))";
! // }
if (!empty ($sidList)) {
! $sql .= " HAVING sid in ($sidList)";
}
$sql .= " ORDER BY unixdate DESC LIMIT 10";
+
$result = DB_query($sql);
$nrows = DB_numRows($result);
- Previous message (by thread): [geeklog-cvs] geeklog-1.3/docs config.html,1.12,1.13 history,1.61,1.62 support.html,1.6,1.7
- Next message (by thread): [geeklog-cvs] A_and_A/client/testscripts AAServiceInterfaceTest.class.php,1.2,1.3 AAUserTest.class.php,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the geeklog-cvs
mailing list