function adserve_cache_id in Advertisement 5.2
Same name and namespace in other branches
- 6.3 adcache.inc \adserve_cache_id()
- 6.2 adcache.inc \adserve_cache_id()
- 7 adcache.inc \adserve_cache_id()
Default function for retrieving list of ids.
File
- ./
adcache.inc, line 214
Code
function adserve_cache_id($type, $id) {
switch ($type) {
case 'nids':
$result = db_query("SELECT aid FROM {ads} WHERE adstatus = 'active' AND aid IN(%d)", $id);
break;
case 'tids':
$result = db_query("SELECT a.aid FROM {ads} a INNER JOIN {term_node} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IN(%d)", $id);
break;
case 'default':
$result = db_query("SELECT a.aid FROM {ads} a LEFT JOIN {term_node} n ON a.aid = n.nid WHERE a.adstatus = 'active' AND n.tid IS NULL");
break;
default:
_debug_echo("Unsupported type '{$type}'.");
}
$ids = array();
while ($ad = db_fetch_object($result)) {
$ids[$ad->aid] = $ad->aid;
}
$number = sizeof($ids);
return $ids;
}