0
저는 joomla 2.5.27과 커뮤니티 빌더 2.0.2를 사용합니다. 는 내가 얻을 커뮤니티 빌더 에 대한 CB 순위 플러그인을 사용 오류SQL 구문 오류가 발생했습니다.
당신은 당신의 SQL 구문에 오류가 있습니다; 올바른 구문은 = 1 호선 SQL에서 근처에 'AND
confirmed
= 1 ANDapproved
= 1'을 사용 r2yze_comprofiler WHEREcb_points
로부터 COUNT (id
)를 선택하는 는 MySQL 서버 버전에 해당하는 설명서를 확인>과confirmed
= 1 ANDapproved
= 1
이 오류
PHP 코드
// Calculate rank
if ($ordertype == "low") {
$_CB_database->setQuery("SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` < $userfield AND `confirmed` = 1 AND `approved` = 1");
}
else {
$_CB_database->setQuery("SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` > $userfield AND `confirmed` = 1 AND `approved` = 1");
}
$value = $_CB_database->loadResult() + 1;
를 해결하는 방법
전체 PHP 코드
<?php
/**
* Joomla Community Builder Rank Field Type Plugin: plug_cbrankfield
* @version $Id$
* @package plug_cbrankfield
* @subpackage cb.rankfield.php
* @author Joe Palmer
* @copyright (C) 2009 www.softforge.co.uk
* @license Limited http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
* @final 1.0
*/
/** ensure this file is being included by a parent file */
if (! (defined('_VALID_CB') || defined('_JEXEC') || defined('_VALID_MOS'))) { die('Direct Access to this location is not allowed.'); }
global $_PLUGINS;
$_PLUGINS->loadPluginGroup('user', array((int) 1));
$_PLUGINS->registerUserFieldTypes(array('rankfield' => 'CBfield_rank'));
$_PLUGINS->registerUserFieldParams();
class CBfield_rank extends CBfield_counter {
/**
* Returns a field in specified format
*
* @param moscomprofilerFields $field
* @param moscomprofilerUser $user
* @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
* @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
* @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
* @return mixed
*/
function getField(&$field, &$user, $output, $reason, $list_compare_types) {
global $_CB_framework, $ueConfig, $_CB_database;
$oReturn = null;
$fieldname = $field->params->get('fieldOrderName', 'hits');
$ordertype = $field->params->get('fieldOrderType', 'high');
$userfield = $user->$fieldname;
// Calculate rank
if ($ordertype == "low") {
$_CB_database->setQuery("SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` < $userfield AND `confirmed` = 1 AND `approved` = 1");
}
else {
$_CB_database->setQuery("SELECT COUNT(`id`) FROM #__comprofiler WHERE `$fieldname` > $userfield AND `confirmed` = 1 AND `approved` = 1");
}
$value = $_CB_database->loadResult() + 1;
switch ($output) {
case 'html':
case 'rss':
$oReturn = $value;
break;
case 'htmledit':
// $oReturn = parent::getField($field, $user, $output, $reason, $list_compare_types);
$oReturn = null; //TBD for now no searches...not optimal in SQL anyway.
break;
case 'json':
case 'php':
case 'xml':
case 'csvheader':
case 'fieldslist':
case 'csv':
default:
$oReturn = $this->_formatFieldOutputIntBoolFloat($field->name, $value, $output);
break;
}
return $oReturn;
}
}//end of rank field
?>