本文整理汇总了PHP中QueryGenerator::addCustomColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryGenerator::addCustomColumn方法的具体用法?PHP QueryGenerator::addCustomColumn怎么用?PHP QueryGenerator::addCustomColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryGenerator
的用法示例。
在下文中一共展示了QueryGenerator::addCustomColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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->addCustomColumn('vtiger_groups.groupname');
foreach ($columnsName as &$column) {
$queryGenerator->addCustomColumn($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];
}
示例2: getUsersAndGroupForModuleList
public function getUsersAndGroupForModuleList($module, $view)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$db = PearDatabase::getInstance();
$queryGenerator = new QueryGenerator($module, $currentUser);
$queryGenerator->initForCustomViewById($view);
$queryGenerator->setFields(['assigned_user_id']);
$queryGenerator->addCustomColumn('vtiger_users.first_name');
$queryGenerator->addCustomColumn('vtiger_users.last_name');
$queryGenerator->addCustomColumn('vtiger_groups.groupname');
$listQuery = $queryGenerator->getQuery('SELECT DISTINCT');
$result = $db->query($listQuery);
$users = $group = [];
while ($row = $db->fetch_array($result)) {
if (isset($row['groupname'])) {
$group[$row['smownerid']] = $row['groupname'];
} else {
$users[$row['smownerid']] = $row['last_name'] . ' ' . $row['first_name'];
}
}
return ['users' => $users, 'group' => $group];
}
示例3: 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->addCustomColumn('userid');
$queryGenerator->addCustomFrom(['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];
}