Kopusha |
|
---|---|
function cot_comments_count($ext_name, $code, $row = array()) { global $db, $db_com; static $com_cache = array(); if (isset($com_cache[$ext_name][$code])) { return $com_cache[$ext_name][$code]; } $cnt = 0; if (isset($row['com_count'])) { $cnt = (int) $row['com_count']; $com_cache[$ext_name][$code] = $cnt; } else { $comments_join_columns = ''; $comments_join_tables = ''; $comments_join_where = ''; /* == Hook == */ foreach (cot_getextplugins('comments.count.query') as $pl) { include $pl; } /* ===== */ $sql = $db->query("SELECT COUNT(*) $comments_join_columns FROM $db_com $comments_join_tables WHERE com_area = ? AND com_code = ? $comments_join_where", array($ext_name, $code)); if ($sql->rowCount() == 1) { $cnt = (int) $sql->fetchColumn(); $com_cache[$ext_name][$code] = $cnt; } } return $cnt; } Собственно код из мастер ветки Такой вопрос - тут создается какой то кеш static $com_cache = array(); $cnt = (int) $row['com_count']; а если нет то $cnt = (int) $sql->fetchColumn(); и $com_cache[$ext_name][$code] = $cnt; |