/** * lấy thông tin detail của một vài c_user,c_user_detail * * @param string $userList danh sách các id c_user * @param object $objConnection connect to db * @param string $selectField các cột sẽ lấy dữ liệu về * @return array thông tin các user * GiaTran */ private function getUserDetailByMultiTable($userList, $objConnection, $selectField = '*') { // build group table - optimize select query $userList = global_common::splitString($userList); //print_r($userList); $arrDocInTable = array(); foreach ($userList as $key) { $suffix = global_common::getTableSuffixByAlphabet($key); $arrDocInTable[$suffix] .= '\'' . $key . '\','; } foreach ($arrDocInTable as $iDoc) { $key = global_common::getTableSuffixByAlphabet(substr($iDoc, 1, 2)); $arrDocInTable[$key] = global_common::cutLast($iDoc, 1); $tbName = global_common::builtTableName(Model_User::TBL_SL_USER, $key); $selectField = '*'; $strSQL .= "(" . global_common::prepareQuery(global_common::SQL_SELECT_BY_CONDITION1, array($selectField, $tbName, '`UserID` IN (' . $arrDocInTable[$key] . ')')) . ') UNION ALL '; } if ($strSQL != '') { $strSQL = substr($strSQL, 0, strlen($strSQL) - strlen(' UNION ALL ')); } if ($selectField == '') { $strSQL = '(select * from (' . $strSQL . ') as tbl_user)'; } else { $strSQL = '(select ' . $selectField . ' from (' . $strSQL . ') as tbl_user)'; } //echo $strSQL; return $objConnection->selectCommand($strSQL); }