cvs: pearweb /include pear-database.php
| From: | Martin Jansen | Date: | Sat, 12 Jun 2004 12:21:51 +0000 |
| Subject: | cvs: pearweb /include pear-database.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-20559@lists.php.net to get a copy of this message | ||
mj Sat Jun 12 08:21:51 2004 EDT
Modified files:
/pearweb/include pear-database.php
Log:
* For each download, the package_stats table is now begin updated
automatically. This enables us to get rid of the package-stats.php
cronjob, which has taken down the MySQL server on pear.php.net numerous
times in the past.
http://cvs.php.net/diff.php/pearweb/include/pear-database.php?r1=1.199&r2=1.200&ty=u
Index: pearweb/include/pear-database.php
diff -u pearweb/include/pear-database.php:1.199 pearweb/include/pear-database.php:1.200
--- pearweb/include/pear-database.php:1.199 Fri Jun 11 01:34:58 2004
+++ pearweb/include/pear-database.php Sat Jun 12 08:21:50 2004
@@ -17,7 +17,7 @@
| Tomas V.V.Cox <cox@php.net> |
| Martin Jansen <mj@php.net> |
+----------------------------------------------------------------------+
- $Id: pear-database.php,v 1.199 2004/06/11 05:34:58 danielc Exp $
+ $Id: pear-database.php,v 1.200 2004/06/12 12:21:50 mj Exp $
*/
require_once 'DB/storage.php';
@@ -1654,9 +1654,8 @@
* Log release download
*
* @param integer ID of the package
- * @param string Version string of the release
+ * @param integer ID of the release
* @param string Filename
- * @return boolean
*/
function logDownload($package, $release_id, $file = null)
{
@@ -1672,11 +1671,33 @@
gethostbyaddr($_SERVER['REMOTE_ADDR'])
));
- if (DB::isError($err)) {
- return false;
+ // {{{ Update package_stats table
+
+ // Check if an entry for the release already exists
+ $query = "SELECT COUNT(pid) FROM package_stats WHERE pid = ? AND rid = ?";
+ $exists = $dbh->getOne($query, array($package, $release_id));
+
+ if ($exists == 0) {
+ $pkg_info = package::info($package);
+ $query = "SELECT version FROM releases WHERE package = ? AND id = ?";
+ $version = $dbh->getOne($query, array($package, $release_id));
+
+ $query = "INSERT INTO package_stats VALUES (1, ?, ?, ?, ?, ?)";
+ $dbh->query($query, array($pkg_info['name'],
+ $version,
+ $package,
+ $release_id,
+ $pkg_info['categoryid']
+ )
+ );
} else {
- return true;
+ $query = "UPDATE package_stats "
+ . " SET dl_number = dl_number + 1 "
+ . " WHERE pid = ? AND rid = ?";
+ $dbh->query($query, array($package, $release_id));
}
+
+ // }}}
}
// }}}