當前位置: 首頁>>代碼示例>>PHP>>正文


PHP icms_db_criteria_Compo::renderWhere方法代碼示例

本文整理匯總了PHP中icms_db_criteria_Compo::renderWhere方法的典型用法代碼示例。如果您正苦於以下問題:PHP icms_db_criteria_Compo::renderWhere方法的具體用法?PHP icms_db_criteria_Compo::renderWhere怎麽用?PHP icms_db_criteria_Compo::renderWhere使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在icms_db_criteria_Compo的用法示例。


在下文中一共展示了icms_db_criteria_Compo::renderWhere方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: synchronize

/**
 * Update count of posts in comments and bb_posts (old forums)
 *
 * @param int $id	Unique ID of the member to synchronize
 * @param str $type	'user' or 'all users'
 */
function synchronize($id, $type) {
	switch($type) {
		case 'user':
			// Array of tables from which to count 'posts'
			$tables = array();
			// Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE)
			include_once ICMS_INCLUDE_PATH . '/comment_constants.php';
			$tables[] = array ('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new icms_db_criteria_Item('com_status', XOOPS_COMMENT_ACTIVE));
			// Count forum posts
			$tables[] = array ('table_name' => 'bb_posts', 'uid_column' => 'uid');
			$total_posts = 0;
			foreach ($tables as $table) {
				$criteria = new icms_db_criteria_Compo();
				$criteria->add (new icms_db_criteria_Item($table['uid_column'], $id));
				if (!empty($table['criteria'])) {$criteria->add ($table['criteria']);}
				$sql = "SELECT COUNT(*) AS total FROM " . icms::$xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere();
				if ($result = icms::$xoopsDB->query($sql)) {
					if ($row = icms::$xoopsDB->fetchArray($result)) {$total_posts = $total_posts + $row['total'];}
				}
			}
			$sql = "UPDATE " . icms::$xoopsDB->prefix("users") . " SET posts = '". (int) $total_posts . "' WHERE uid = '". (int) $id . "'";
			if (!$result = icms::$xoopsDB->query($sql)) {exit(sprintf(_AM_CNUUSER %s , $id));}
			break;

		case 'all users':
			$sql = "SELECT uid FROM " . icms::$xoopsDB->prefix('users') . "";
			if (!$result = icms::$xoopsDB->query($sql)) {exit(_AM_CNGUSERID);}
			while ($row = icms::$xoopsDB->fetchArray($result)) {
				$id = $row['uid'];
				synchronize($id, "user");
			}
			break;

		default:
			break;
	}
	redirect_header('admin.php?fct=users&op=modifyUser&uid=' . $id, 1, _AM_DBUPDATED);
	exit();
}
開發者ID:nao-pon,項目名稱:impresscms,代碼行數:45,代碼來源:users.php


注:本文中的icms_db_criteria_Compo::renderWhere方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。