Changeset 1085 for trunk/common
- Timestamp:
- 12/22/09 14:06:43 (2 years ago)
- File:
-
- 1 edited
-
trunk/common/db/tags.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/tags.php
r1084 r1085 3 3 require_once(IA_ROOT_DIR."common/db/db.php"); 4 4 require_once(IA_ROOT_DIR."common/common.php"); 5 require_once(IA_ROOT_DIR."common/cache.php"); 5 6 6 7 // Get list of all tag names, filtered by type and parent … … 183 184 184 185 // Count the number of objects containing all tags from a list of tag ids 185 function tag_count_objects($obj, $tag_ids ) {186 function tag_count_objects($obj, $tag_ids, $no_cache=false) { 186 187 log_assert(is_taggable($obj)); 187 188 log_assert(is_array($tag_ids)); 189 // Cache object count for single tags. 190 if (!$no_cache && count($tag_ids) == 1) { 191 $result = mem_cache_get("$obj-count-with-tag:".$tag_ids[0]); 192 if ($result !== false) { 193 return $result; 194 } 195 } 188 196 $query = sprintf("SELECT COUNT(*) as `cnt` FROM ia_%s WHERE %s", db_escape($obj), 189 197 tag_build_where($obj, $tag_ids)); 190 198 $result = db_fetch($query); 191 return $result['cnt']; 199 $result = $result['cnt']; 200 if (count($tag_ids) == 1) { 201 mem_cache_set("$obj-count-with-tag:".$tag_ids[0], $result, 202 IA_MEM_CACHE_TAGS_EXPIRATION); 203 } 204 return $result; 192 205 } 193 206
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)