本文整理汇总了PHP中plgFabrik_Element::getAvgQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP plgFabrik_Element::getAvgQuery方法的具体用法?PHP plgFabrik_Element::getAvgQuery怎么用?PHP plgFabrik_Element::getAvgQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plgFabrik_Element
的用法示例。
在下文中一共展示了plgFabrik_Element::getAvgQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvgQuery
/**
* Build the query for the avg calculation
*
* @param model &$listModel list model
* @param string $label the label to apply to each avg
*
* @return string sql statement
*/
protected function getAvgQuery(&$listModel, $label = "'calc'")
{
$db = $listModel->getDb();
$fields = $listModel->getDBFields($this->getTableName(), 'Field');
$name = $this->getElement()->name;
$field = JArrayHelper::getValue($fields, $name, false);
if ($field !== false && $field->Type == 'time') {
$name = $this->getFullName(false, false, false);
$table = $listModel->getTable();
$joinSQL = $listModel->_buildQueryJoin();
$whereSQL = $listModel->_buildQueryWhere();
return "SELECT SEC_TO_TIME(AVG(TIME_TO_SEC({$name}))) AS value, {$label} AS label FROM " . $db->quoteName($table->db_table_name) . " {$joinSQL} {$whereSQL}";
} else {
return parent::getAvgQuery($listModel, $label);
}
}
示例2: getAvgQuery
/**
* build the query for the avg caclculation
* @param model $listModel
* @param string $label the label to apply to each avg
* @return string sql statement
*/
protected function getAvgQuery(&$listModel, $label = "'calc'")
{
$fields = $listModel->getDBFields($this->getTableName(), 'Field');
if ($fields[$this->getElement()->name]->Type == 'time') {
$name = $this->getFullName(false, false, false);
$table =& $listModel->getTable();
$joinSQL = $listModel->_buildQueryJoin();
$whereSQL = $listModel->_buildQueryWhere();
return "SELECT SEC_TO_TIME(AVG(TIME_TO_SEC({$name}))) AS value, {$label} AS label FROM `{$table->db_table_name}` {$joinSQL} {$whereSQL}";
} else {
return parent::getAvgQuery($listModel, $label);
}
}