本文整理汇总了PHP中ARSelectFilter::getFieldList方法的典型用法代码示例。如果您正苦于以下问题:PHP ARSelectFilter::getFieldList方法的具体用法?PHP ARSelectFilter::getFieldList怎么用?PHP ARSelectFilter::getFieldList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARSelectFilter
的用法示例。
在下文中一共展示了ARSelectFilter::getFieldList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createStatementBody
/**
* Creates a string representing SQL SELECT query
*
* @return string
*/
private function createStatementBody()
{
$filterFieldList = $this->filter instanceof ARSelectFilter ? $this->filter->getFieldList() : array();
$fields = array_merge($this->fieldList, $filterFieldList);
$tableAliases = array();
$fieldListStr = "";
$preparedFieldList = array();
if (empty($fields)) {
$fieldStr = "*";
} else {
foreach ($fields as $fieldInfo) {
$field = "";
if (!empty($fieldInfo['tableName'])) {
$field = $fieldInfo['tableName'] . "." . $fieldInfo['fieldName'];
} else {
$field = $fieldInfo['fieldName'];
}
if (!empty($fieldInfo['fieldNameInResult'])) {
$field .= ' AS "' . $fieldInfo['fieldNameInResult'] . '"';
}
$preparedFieldList[] = $field;
}
}
$fieldListStr = implode(", ", $preparedFieldList);
$tableListStr = implode(", ", array_keys($this->tableList));
// add joins from select filter
$filterJoins = $this->filter->getJoinList();
$joins = array_merge($this->joinList, $filterJoins);
$joinListStr = "";
if (!empty($joins)) {
$preparedJoinList = array();
foreach ($joins as $joinItem) {
if (!empty($joinItem['tableAliasName'])) {
$alias = ' AS `' . $joinItem['tableAliasName'] . '`';
$tableName = $joinItem['tableAliasName'];
} else {
$alias = '';
$tableName = $joinItem['tableName'];
}
if (empty($joinItem['tableAliasName'])) {
$tableAliases[$joinItem['tableName']] = $joinItem['tableName'];
} else {
if (!isset($tableAliases[$joinItem['tableName']])) {
$tableAliases[$joinItem['tableName']] = $joinItem['tableAliasName'];
}
}
$preparedJoinList[] = "LEFT JOIN `" . $joinItem['tableName'] . '`' . $alias . " ON " . (isset($tableAliases[$joinItem['mainTableName']]) ? $tableAliases[$joinItem['mainTableName']] : $joinItem['mainTableName']) . "." . $joinItem['mainTableJoinFieldName'] . " = " . $tableName . "." . $joinItem['tableJoinFieldName'] . '';
}
$joinListStr = implode(" ", $preparedJoinList);
}
return "SELECT " . $fieldListStr . " FROM " . $tableListStr . " " . $joinListStr;
}
示例2: merge
/**
* Merges two filters (filter supplied as parameter overwrites order and limit
* params of this filter)
*
* @param ARSelectFilter $filter
*/
public function merge(ARSelectFilter $filter)
{
if ($filter->isConditionSet()) {
$this->mergeCondition($filter->getCondition());
}
if ($filter->isHavingConditionSet()) {
$this->mergeHavingCondition($filter->getHavingCondition());
}
$this->setFieldOrder($filter->getFieldOrder());
$this->setLimit($filter->getLimit(), $filter->getOffset());
$groupings = $filter->getGroupingFields();
$this->fieldListForGroup = array_merge($this->getGroupingFields(), $groupings);
$joins = $filter->getJoinList();
$this->joinList = array_merge($this->joinList, $joins);
$fields = $filter->getFieldList();
$this->fieldList = array_merge($this->fieldList, $fields);
}