本文整理汇总了PHP中QueryGenerator::setCustomColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryGenerator::setCustomColumn方法的具体用法?PHP QueryGenerator::setCustomColumn怎么用?PHP QueryGenerator::setCustomColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryGenerator
的用法示例。
在下文中一共展示了QueryGenerator::setCustomColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSearchViewList
public function getSearchViewList($module, $view)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$db = PearDatabase::getInstance();
$queryGenerator = new QueryGenerator($module, $currentUser);
$meta = $queryGenerator->getMeta($module);
$baseTable = $meta->getEntityBaseTable();
$tableIndexList = $meta->getEntityTableIndexList();
$baseTableIndex = $tableIndexList[$baseTable];
$queryGenerator->initForCustomViewById($view);
$queryGenerator->setFields([]);
$queryGenerator->setCustomColumn('userid');
$queryGenerator->setCustomFrom(['joinType' => 'INNER', 'relatedTable' => 'u_yf_crmentity_showners', 'relatedIndex' => 'crmid', 'baseTable' => $baseTable, 'baseIndex' => $baseTableIndex]);
$listQuery = $queryGenerator->getQuery('SELECT DISTINCT');
$result = $db->query($listQuery);
$users = $group = [];
while ($id = $db->getSingleValue($result)) {
$name = self::getUserName($id);
if ($name !== false) {
$users[$id] = $name;
continue;
}
$name = self::getGroupName($id);
if ($name !== false) {
$group[$id] = $name;
continue;
}
}
asort($users);
asort($group);
return ['users' => $users, 'group' => $group];
}
示例2: getRelationQuery
/**
* Function to get relation query for particular module with function name
* @param <record> $recordId
* @param <String> $functionName
* @param Vtiger_Module_Model $relatedModule
* @return <String>
*/
public function getRelationQuery($recordId, $functionName, $relatedModule, $relationModel = false)
{
$relatedModuleName = $relatedModule->getName();
$focus = CRMEntity::getInstance($this->getName());
$focus->id = $recordId;
switch ($functionName) {
case 'get_many_to_many':
$query = $this->getRelationQueryM2M($recordId, $relatedModule, $relationModel);
break;
case 'get_activities':
$query = $this->getRelationQueryForActivities($recordId, $relatedModule, $relationModel);
break;
default:
$result = $focus->{$functionName}($recordId, $this->getId(), $relatedModule->getId());
$query = $result['query'] . ' ' . $this->getSpecificRelationQuery($relatedModuleName);
break;
}
//modify query if any module has summary fields, those fields we are displayed in related list of that module
$relatedListFields = [];
if ($relationModel) {
$relatedListFields = $relationModel->getRelationFields(true, true);
}
if (count($relatedListFields) == 0) {
$relatedListFields = $relatedModule->getConfigureRelatedListFields();
if ($relatedModuleName == 'Documents') {
$relatedListFields['filelocationtype'] = 'filelocationtype';
$relatedListFields['filestatus'] = 'filestatus';
}
}
if (count($relatedListFields) > 0) {
$currentUser = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($relatedModuleName, $currentUser);
$queryGenerator->setFields($relatedListFields);
if ($relationModel->showCreatorDetail()) {
$queryGenerator->setCustomColumn('rel_created_user');
$queryGenerator->setCustomColumn('rel_created_time');
}
if ($relationModel->showComment()) {
$queryGenerator->setCustomColumn('rel_comment');
}
$selectColumnSql = $queryGenerator->getSelectClauseColumnSQL();
$query = str_replace('FROM', 'from', $query);
$newQuery = explode('from', $query);
$selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid,' . $selectColumnSql;
$query = $selectColumnSql . ' FROM ' . $newQuery[1];
}
$instance = CRMEntity::getInstance($relatedModuleName);
$securityParameter = $instance->getUserAccessConditionsQuerySR($relatedModuleName, false, $recordId);
if ($securityParameter != '') {
$query .= $securityParameter;
}
return $query;
}
示例3: getUsersAndGroupForModuleList
public function getUsersAndGroupForModuleList($module, $view)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$db = PearDatabase::getInstance();
$userEntityInfo = Vtiger_Functions::getEntityModuleInfo('Users');
$table = $userEntityInfo['tablename'];
$columnsName = explode(',', $userEntityInfo['fieldname']);
$queryGenerator = new QueryGenerator($module, $currentUser);
$queryGenerator->initForCustomViewById($view);
$queryGenerator->setFields(['assigned_user_id']);
$queryGenerator->setCustomColumn('vtiger_groups.groupname');
foreach ($columnsName as &$column) {
$queryGenerator->setCustomColumn($table . '.' . $column);
}
$listQuery = $queryGenerator->getQuery('SELECT DISTINCT');
$listQuery .= ' ORDER BY last_name ASC, first_name ASC';
$result = $db->query($listQuery);
$users = $group = [];
while ($row = $db->fetch_array($result)) {
if (isset($row['groupname'])) {
$group[$row['smownerid']] = $row['groupname'];
} else {
$name = '';
foreach ($columnsName as &$column) {
$name .= $row[$column] . ' ';
}
$users[$row['smownerid']] = trim($name);
}
}
return ['users' => $users, 'group' => $group];
}