|
cvs: pearweb /include pear-database.php: msg#00041php.pear.core
cellog Wed Oct 18 00:42:01 2006 UTC Modified files: /pearweb/include pear-database.php Log: store downloads directly in aggregated_package_stats table # step 5 is update database and pear-database.php, make sure it works # step 6 is delete old downloads from downloads, run update script truncate downloads http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database.php?r1=1.315&r2=1.316&diff_format=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.315 pearweb/include/pear-database.php:1.316 --- pearweb/include/pear-database.php:1.315 Sun Oct 15 08:44:56 2006 +++ pearweb/include/pear-database.php Wed Oct 18 00:42:01 2006 @@ -13,11 +13,12 @@ | obtain it through the world-wide-web, please send a note to | | license@xxxxxxx so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Stig Sæther Bakken <ssb@xxxxxxx> | + | Authors: Stig Bakken <ssb@xxxxxxx> | | Tomas V.V.Cox <cox@xxxxxxx> | | Martin Jansen <mj@xxxxxxx> | + | Gregory Beaver <cellog@xxxxxxx> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.315 2006/10/15 08:44:56 arnaud Exp $ + $Id: pear-database.php,v 1.316 2006/10/18 00:42:01 cellog Exp $ */ require_once 'DB/storage.php'; @@ -2108,17 +2109,48 @@ { global $dbh; - $id = $dbh->nextId("downloads"); - - $query = "INSERT INTO downloads (id, file, package, release, dl_when, dl_who) VALUES (?, ?, ?, ?, ?, ?)"; + $dbh->query('UPDATE aggregated_package_stats + SET downloads=downloads+1 + WHERE + package_id=? AND + release_id=? AND + yearmonth="' . date('Y-m-01') . '"', + array($package, $release_id)); + if ($dbh->affectedRows() == 0) { + $dbh->query('INSERT INTO aggregated_package_stats + (package_id, release_id, yearmonth, downloads) + VALUES(?,?,?,1)', + array($package, $release_id, date('Y-m-01'))); + } - $err = $dbh->query($query, array($id, (int)$file, $package, - $release_id, date("Y-m-d H:i:s"), - $_SERVER['REMOTE_ADDR'] - )); +// This method can be used when we have MySQL 4.1, +// 30% efficiency gain at least over previous method +// $dbh->query('INSERT INTO aggregated_package_stats +// (package_id, release_id, yearmonth, downloads) +// VALUES(?,?,?,1) +// ON DUPLICATE KEY UPDATE downloads=downloads+1', +// array($package, $release_id, date('Y-m-01'))); // {{{ Update package_stats table +// This method can be used when we have MySQL 4.1, +// 30% efficiency gain at least over previous method +// $query = 'INSERT INTO package_stats +// (dl_number, package, release, pid, rid, cid, last_dl) +// VALUES (1, ?, ?, ?, ?, ?, ?) +// ON DUPLICATE KEY UPDATE +// dl_number=dl_number+1, +// last_dl = "' . date('Y-m-d H:i:s') . '"'; +// +// $dbh->query($query, array($pkg_info['name'], +// $version, +// $package, +// $release_id, +// $pkg_info['categoryid'], +// date('Y-m-d H:i:s') +// ) +// ); + $query = 'UPDATE package_stats ' . ' SET dl_number = dl_number + 1,' . " last_dl = '" . date('Y-m-d H:i:s') . "'" |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | cvs: pearweb /public_html package-stats-graph.php: 00041, Greg Beaver |
|---|---|
| Next by Date: | cvs: pearweb /public_html package-stats.php: 00041, Greg Beaver |
| Previous by Thread: | cvs: pearweb /include pear-database.phpi: 00041, Arnaud Limbourg |
| Next by Thread: | cvs: pearweb /include pear-database.php: 00041, Greg Beaver |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |