оно работает только в +
Код: Выделить всё
UPDATE phpbb_users SET user_old_posts = user_posts WHERE user_id <> 1;И как в моем случае это будет выглядеть?
Код: Выделить всё
UPDATE phpbb_users SET user_old_posts = user_posts WHERE user_id <> 1;Код: Выделить всё
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$sql = 'SELECT user_id FROM '.USERS_TABLE.' WHERE user_id <> 1';
$result = $db->sql_query($sql);
while($data = $db->sql_fetchrow($result))
{
$sql = 'SELECT COUNT(post_id) AS posts FROM '.POSTS_TABLE.' WHERE poster_id = '.$data['user_id'].'';
$res = $db->sql_query($sql);
$posts = (int) $db->sql_fetchfield('posts');
$db->sql_freeresult($res);
$sql = 'UPDATE '.USERS_TABLE.' SET user_old_posts = '.$posts.' WHERE user_id = '.$data['user_id'].'';
$db->sql_query($sql);
}
$db->sql_freeresult($result);
trigger_error('Ok');
?>Код: Выделить всё
$sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_approval) ? ',user_old_posts = user_posts + 1, user_posts = user_posts + 1' : '');user_old_posts = user_posts + 1Код: Выделить всё
SET user_posts = user_posts + ' . $user_posts . 'Код: Выделить всё
SET user_posts = user_posts + ' . $user_posts . ', user_old_posts = user_old_posts + ' . $user_posts . '