本文整理汇总了PHP中qa_should_update_counts函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_should_update_counts函数的具体用法?PHP qa_should_update_counts怎么用?PHP qa_should_update_counts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_should_update_counts函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qa_db_hotness_update
function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false)
{
if (qa_should_update_counts()) {
if (!isset($lastpostid)) {
$lastpostid = $firstpostid;
}
$query = 'UPDATE ^posts AS x, (SELECT parents.postid, parents.created AS qcreated, COALESCE(MAX(children.created), parents.created) as acreated, COUNT(children.postid) AS acount, parents.netvotes, parents.views FROM ^posts AS parents LEFT JOIN ^posts AS children ON parents.postid=children.parentid AND children.type=\'A\' WHERE parents.postid>=# AND parents.postid<=# AND parents.type=\'Q\' GROUP BY postid) AS a SET x.hotness=(' . '((TO_DAYS(a.qcreated)-734138)*86400.0+TIME_TO_SEC(a.qcreated))*# + ' . '((TO_DAYS(a.acreated)-734138)*86400.0+TIME_TO_SEC(a.acreated))*# + ' . '(a.acount+0.0)*# + ' . '(a.netvotes+0.0)*# + ' . '(a.views+0.0+#)*#' . ')' . ($viewincrement ? ', x.views=x.views+1, x.lastviewip=INET_ATON($)' : '') . ' WHERE x.postid=a.postid';
// Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors
$arguments = array($firstpostid, $lastpostid, qa_opt('hot_weight_q_age'), qa_opt('hot_weight_a_age'), qa_opt('hot_weight_answers') * 160000, qa_opt('hot_weight_votes') * 160000, $viewincrement ? 1 : 0, qa_opt('hot_weight_views') * 4000);
if ($viewincrement) {
$arguments[] = qa_remote_ip_address();
}
qa_db_query_raw(qa_db_apply_sub($query, $arguments));
}
}
示例2: qa_db_queuedcount_update
function qa_db_queuedcount_update()
{
if (qa_should_update_counts()) {
qa_db_query_sub("REPLACE ^options (title, content) SELECT 'cache_queuedcount', COUNT(*) FROM ^posts WHERE type IN ('Q_QUEUED', 'A_QUEUED', 'C_QUEUED')");
}
}
示例3: qa_db_post_recount_flags
function qa_db_post_recount_flags($postid)
{
if (qa_should_update_counts()) {
qa_db_query_sub('UPDATE ^posts AS x, (SELECT COALESCE(SUM(IF(flag, 1, 0)),0) AS flagcount FROM ^uservotes WHERE postid=#) AS a SET x.flagcount=a.flagcount WHERE x.postid=#', $postid, $postid);
}
}
示例4: qa_db_uapprovecount_update
function qa_db_uapprovecount_update()
{
if (qa_should_update_counts() && !QA_FINAL_EXTERNAL_USERS) {
qa_db_query_sub("REPLACE ^options (title, content) SELECT 'cache_uapprovecount', COUNT(*) FROM ^users WHERE level<# AND NOT (flags&#)", QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_USER_BLOCKED);
}
}
示例5: qa_db_unupaqcount_update
function qa_db_unupaqcount_update()
{
if (qa_should_update_counts()) {
qa_db_query_sub("REPLACE ^options (title, content) SELECT 'cache_unupaqcount', COUNT(*) FROM ^posts WHERE type='Q' AND amaxvote=0");
}
}
示例6: qa_db_userpointscount_update
function qa_db_userpointscount_update()
{
if (qa_should_update_counts()) {
qa_db_query_sub("REPLACE ^options (title, content) SELECT 'cache_userpointscount', COUNT(*) FROM ^userpoints");
}
}
示例7: qa_db_queuedcount_update
function qa_db_queuedcount_update()
{
if (qa_should_update_counts()) {
qa_db_query_sub("INSERT INTO ^options (title, content) " . "SELECT 'cache_queuedcount', COUNT(*) FROM ^posts " . "WHERE type IN ('Q_QUEUED', 'A_QUEUED', 'C_QUEUED') " . "ON DUPLICATE KEY UPDATE content = VALUES(content)");
}
}
示例8: qa_db_flaggedcount_update
function qa_db_flaggedcount_update()
{
if (qa_should_update_counts()) {
qa_db_query_sub("REPLACE ^options (title, content) SELECT 'cache_flaggedcount', COUNT(*) FROM ^posts WHERE flagcount>0 AND type IN ('Q', 'A', 'C')");
}
}
示例9: qa_db_user_recount_posts
function qa_db_user_recount_posts($userid)
{
if (qa_should_update_counts()) {
qa_db_query_sub("UPDATE ^users AS x, (SELECT COUNT(*) AS wallposts FROM ^messages WHERE touserid=# AND type='PUBLIC') AS a SET x.wallposts=a.wallposts WHERE x.userid=#", $userid, $userid);
}
}
示例10: qa_db_uapprovecount_update
function qa_db_uapprovecount_update()
{
if (qa_should_update_counts() && !QA_FINAL_EXTERNAL_USERS) {
qa_db_query_sub("INSERT INTO ^options (title, content) " . "SELECT 'cache_uapprovecount', COUNT(*) FROM ^users " . "WHERE level < # AND NOT (flags & #) " . "ON DUPLICATE KEY UPDATE content = VALUES(content)", QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_USER_BLOCKED);
}
}
示例11: qa_db_userpointscount_update
function qa_db_userpointscount_update()
{
if (qa_should_update_counts()) {
qa_db_query_sub("INSERT INTO ^options (title, content) " . "SELECT 'cache_userpointscount', COUNT(*) FROM ^userpoints " . "ON DUPLICATE KEY UPDATE content = VALUES(content)");
}
}