[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1236] try caching tagcloud queries
From: |
Clint Adams |
Subject: |
[Librefm-commits] [1236] try caching tagcloud queries |
Date: |
Wed, 06 May 2009 19:54:00 +0000 |
Revision: 1236
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1236
Author: clint
Date: 2009-05-06 19:53:59 +0000 (Wed, 06 May 2009)
Log Message:
-----------
try caching tagcloud queries
Modified Paths:
--------------
trunk/nixtape/data/TagCloud.php
Modified: trunk/nixtape/data/TagCloud.php
===================================================================
--- trunk/nixtape/data/TagCloud.php 2009-05-06 19:33:50 UTC (rev 1235)
+++ trunk/nixtape/data/TagCloud.php 2009-05-06 19:53:59 UTC (rev 1236)
@@ -18,7 +18,7 @@
*/
-require_once($install_path . '/database.php');
+require_once($install_path . '/database2.php');
require_once($install_path . '/data/Server.php');
class TagCloud {
@@ -33,7 +33,7 @@
* @return array tagcloud
*/
static function generateTagCloud($table, $field, $limit = 40, $constraint
= null, $constrained_field = false) {
- global $mdb2;
+ global $adodb;
if (!is_string($field)) return false;
if (!is_string($table)) return false;
if (!is_integer($limit)) return false;
@@ -48,18 +48,16 @@
$query .= (!is_null($constraint)) ? ' username = ' .
$mdb2->quote($constraint, 'text') : null;
}
$query .= " GROUP BY $field ORDER BY count DESC LIMIT $limit";
- $res = $mdb2->query($query);
- if (PEAR::isError($res)) {
- echo("ERROR - " . $res->getMessage());
+ $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+ $res = $adodb->CacheGetAll(7200,$query);
+ if (!$res) {
+ echo("ERROR");
}
- if (!$res->numRows()) {
- return false;
} else {
- $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
- foreach($data as $count => &$i) {
+ foreach($res as $count => &$i) {
$i['size'] = $sizes[(int) ($count/(count($data)/7))];
}
- foreach($data as &$i){
+ foreach($res as &$i){
$i['pageurl'] = Server::getArtistURL($i['artist']);
}
sort($data);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1236] try caching tagcloud queries,
Clint Adams <=