Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ERROR:
- 1690 - BIGINT UNSIGNED value is out of range in '(`medziokle_press`.`c`.`isgood` - `medziokle_press`.`c`.`ispoor`)' SQL=SELECT c.userid, '' as avatar, '' as profileLink , CASE WHEN c.userid = 0 THEN c.email ELSE u.email END AS email , CASE WHEN c.userid = 0 THEN c.name ELSE u.name END AS name , CASE WHEN c.userid = 0 THEN c.username ELSE u.username END AS username , COUNT(c.userid) AS commentsCount , SUM(c.isgood) AS isgood, SUM(c.ispoor) AS ispoor, SUM(c.isgood - c.ispoor) AS votes FROM v9465_jcomments AS c LEFT JOIN v9465_users AS u ON u.id = c.userid WHERE c.published = 1 AND c.deleted = 0 GROUP BY c.userid, email, name, username, avatar, profileLink ORDER BY commentsCount DESC LIMIT 0, 25
- code which is making this query:
- <?php
- // no direct access
- defined('_JEXEC') or die;
- class modJCommentsTopPostersHelper
- {
- static function getList( &$params )
- {
- $db = JFactory::getDBO();
- $interval = $params->get('interval', '');
- $where = array();
- if (!empty($interval)) {
- $date = JFactory::getDate();
- $timestamp = $date->toUnix();
- switch($interval) {
- case '1-day':
- $timestamp = strtotime('-1 day', $timestamp);
- break;
- case '1-week':
- $timestamp = strtotime('-1 week', $timestamp);
- break;
- case '2-week':
- $timestamp = strtotime('-2 week', $timestamp);
- break;
- case '1-month':
- $timestamp = strtotime('-1 month', $timestamp);
- break;
- case '3-month':
- $timestamp = strtotime('-3 month', $timestamp);
- break;
- case '6-month':
- $timestamp = strtotime('-6 month', $timestamp);
- break;
- case '1-year':
- $timestamp = strtotime('-1 year', $timestamp);
- break;
- default:
- $timestamp = NULL;
- break;
- }
- if ($timestamp !== NULL) {
- if (version_compare(JVERSION,'1.6.0','ge')) {
- $dateFrom = JFactory::getDate($timestamp)->toSql();
- $dateTo = $date->toSql();
- } else {
- $dateFrom = JFactory::getDate($timestamp)->toMySql();
- $dateTo = $date->toMySQL();
- }
- $where[] = 'c.date BETWEEN ' . $db->Quote($dateFrom) . ' AND ' . $db->Quote($dateTo);
- }
- }
- switch($params->get('ordering', ''))
- {
- case 'votes':
- $orderBy = 'votes DESC';
- break;
- case 'comments':
- default:
- $orderBy = 'commentsCount DESC';
- break;
- }
- $where[] = 'c.published = 1';
- $where[] = 'c.deleted = 0';
- $query = "SELECT c.userid, '' as avatar, '' as profileLink"
- . " , CASE WHEN c.userid = 0 THEN c.email ELSE u.email END AS email"
- . " , CASE WHEN c.userid = 0 THEN c.name ELSE u.name END AS name"
- . " , CASE WHEN c.userid = 0 THEN c.username ELSE u.username END AS username"
- . " , COUNT(c.userid) AS commentsCount"
- . " , SUM(c.isgood) AS isgood, SUM(c.ispoor) AS ispoor, SUM(c.isgood - c.ispoor) AS votes"
- . " FROM #__jcomments AS c"
- . " LEFT JOIN #__users AS u ON u.id = c.userid"
- . (count($where) ? ' WHERE ' . implode(' AND ', $where) : '')
- . " GROUP BY c.userid, email, name, username, avatar, profileLink"
- . " ORDER BY " . $orderBy
- ;
- $db->setQuery($query, 0, $params->get('count'));
- $list = $db->loadObjectList();
- $show_avatar = $params->get('show_avatar', 0);
- if ($show_avatar) {
- JPluginHelper::importPlugin('jcomments');
- if (version_compare(JVERSION, '3.0', 'ge')) {
- $dispatcher = JEventDispatcher::getInstance();
- } else {
- $dispatcher = JDispatcher::getInstance();
- }
- $dispatcher->trigger('onPrepareAvatars', array(&$list));
- }
- foreach($list as &$item) {
- $item->displayAuthorName = JComments::getCommentAuthorName($item);
- if ($show_avatar && empty($item->avatar)) {
- $gravatar = md5(strtolower($item->email));
- $item->avatar = '<img src="http://www.gravatar.com/avatar.php?gravatar_id='. $gravatar .'&default=' . urlencode(JCommentsFactory::getLink('noavatar')) . '" alt="'.htmlspecialchars(JComments::getCommentAuthorName($item)).'" />';
- }
- }
- return $list;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement