本文整理汇总了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();
}