本文整理汇总了PHP中CDBResult::NavQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP CDBResult::NavQuery方法的具体用法?PHP CDBResult::NavQuery怎么用?PHP CDBResult::NavQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDBResult
的用法示例。
在下文中一共展示了CDBResult::NavQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NavQuery
function NavQuery($arNavParams, $arQuerySelect, $strTableName, $strQueryWhere, $arQueryOrder)
{
global $DB;
if (IntVal($arNavParams["nTopCount"]) <= 0) {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tcount(1) C\n\t\t\t\tFROM\n\t\t\t\t\t" . $strTableName . " t\n\t\t\t";
if ($strQueryWhere) {
$strSql .= "\n\t\t\t\t\tWHERE\n\t\t\t\t\t" . $strQueryWhere . "\n\t\t\t\t";
}
$res_cnt = $DB->Query($strSql);
$res_cnt = $res_cnt->Fetch();
$cnt = $res_cnt["C"];
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t" . implode(", ", $arQuerySelect) . "\n\t\t\t\tFROM\n\t\t\t\t\t" . $strTableName . " t\n\t\t\t";
if ($strQueryWhere) {
$strSql .= "\n\t\t\t\t\tWHERE\n\t\t\t\t\t" . $strQueryWhere . "\n\t\t\t\t";
}
if (count($arQueryOrder) > 0) {
$strSql .= "\n\t\t\t\t\tORDER BY\n\t\t\t\t\t" . implode(", ", $arQueryOrder) . "\n\t\t\t\t";
}
$res = new CDBResult();
$res->NavQuery($strSql, $cnt, $arNavParams);
return $res;
} else {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t" . implode(", ", $arQuerySelect) . "\n\t\t\t\tFROM\n\t\t\t\t\t" . $strTableName . " t\n\t\t\t";
if ($strQueryWhere) {
$strSql .= "\n\t\t\t\t\tWHERE\n\t\t\t\t\t" . $strQueryWhere . "\n\t\t\t\t";
}
if (count($arQueryOrder) > 0) {
$strSql .= "\n\t\t\t\t\tORDER BY\n\t\t\t\t\t" . implode(", ", $arQueryOrder) . "\n\t\t\t\t";
}
return $DB->Query($DB->TopSql($strSql, intval($arNavParams["nTopCount"])));
}
}
示例2: GetNotifyList
public function GetNotifyList($arParams)
{
global $DB;
$iNumPage = 1;
if (isset($arParams['PAGE']) && intval($arParams['PAGE']) > 0) {
$iNumPage = intval($arParams['PAGE']);
}
$bTimeZone = isset($arParams['USE_TIME_ZONE']) && $arParams['USE_TIME_ZONE'] == 'N' ? false : true;
$sqlStr = "\n\t\t\tSELECT COUNT(M.ID) as CNT\n\t\t\tFROM b_im_relation R\n\t\t\tINNER JOIN b_im_message M ON M.NOTIFY_READ = 'Y' AND M.CHAT_ID = R.CHAT_ID\n\t\t\tWHERE R.USER_ID = " . $this->user_id . " AND R.MESSAGE_TYPE = '" . IM_MESSAGE_SYSTEM . "'\n\t\t";
$res_cnt = $DB->Query($sqlStr);
$res_cnt = $res_cnt->Fetch();
$cnt = $res_cnt["CNT"];
$arNotify = array();
if ($cnt > 0) {
if (!$bTimeZone) {
CTimeZone::Disable();
}
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tM.ID,\n\t\t\t\t\tM.CHAT_ID,\n\t\t\t\t\tM.MESSAGE,\n\t\t\t\t\tM.MESSAGE_OUT,\n\t\t\t\t\t" . $DB->DateToCharFunction('M.DATE_CREATE') . " DATE_CREATE,\n\t\t\t\t\tM.NOTIFY_TYPE,\n\t\t\t\t\tM.NOTIFY_MODULE,\n\t\t\t\t\tM.NOTIFY_TITLE,\n\t\t\t\t\tM.NOTIFY_BUTTONS,\n\t\t\t\t\tM.NOTIFY_TAG,\n\t\t\t\t\tM.NOTIFY_SUB_TAG,\n\t\t\t\t\tM.NOTIFY_READ,\n\t\t\t\t\tR.LAST_ID,\n\t\t\t\t\tR.USER_ID TO_USER_ID,\n\t\t\t\t\tM.AUTHOR_ID FROM_USER_ID\n\t\t\t\tFROM b_im_relation R\n\t\t\t\tINNER JOIN b_im_message M ON M.NOTIFY_READ = 'Y' AND M.CHAT_ID = R.CHAT_ID\n\t\t\t\tWHERE R.USER_ID = " . $this->user_id . " AND R.MESSAGE_TYPE = '" . IM_MESSAGE_SYSTEM . "'\n\t\t\t\tORDER BY M.DATE_CREATE DESC, ID DESC\n\t\t\t";
if (!$bTimeZone) {
CTimeZone::Enable();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, array('iNumPage' => $iNumPage, 'nPageSize' => 20));
while ($arRes = $dbRes->Fetch()) {
if ($this->bHideLink) {
$arRes['HIDE_LINK'] = 'Y';
}
$arNotify[$arRes['ID']] = self::GetFormatNotify($arRes);
}
}
return $arNotify;
}
示例3: GetList
static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
$arFields = array("ID" => array("FIELD" => "CP.ID", "TYPE" => "int"), "PRODUCT_ID" => array("FIELD" => "CP.PRODUCT_ID", "TYPE" => "int"), "STORE_ID" => array("FIELD" => "CP.STORE_ID", "TYPE" => "int"), "AMOUNT" => array("FIELD" => "CP.AMOUNT", "TYPE" => "double"), "STORE_NAME" => array("FIELD" => "CS.TITLE", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"), "STORE_ADDR" => array("FIELD" => "CS.ADDRESS", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"), "STORE_DESCR" => array("FIELD" => "CS.DESCRIPTION", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"), "STORE_GPS_N" => array("FIELD" => "CS.GPS_N", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"), "STORE_GPS_S" => array("FIELD" => "CS.GPS_S", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"), "STORE_IMAGE" => array("FIELD" => "CS.IMAGE_ID", "TYPE" => "int", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"), "STORE_LOCATION" => array("FIELD" => "CS.LOCATION_ID", "TYPE" => "int", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"));
$arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_catalog_store_product CP " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return false;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_catalog_store_product CP " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_catalog_store_product CP " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例4: GetList
function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
$arFields = array("ID" => array("FIELD" => "CPG.ID", "TYPE" => "int"), "PRODUCT_ID" => array("FIELD" => "CPG.PRODUCT_ID", "TYPE" => "int"), "GROUP_ID" => array("FIELD" => "CPG.GROUP_ID", "TYPE" => "int"), "ACCESS_LENGTH" => array("FIELD" => "CPG.ACCESS_LENGTH", "TYPE" => "int"), "ACCESS_LENGTH_TYPE" => array("FIELD" => "CPG.ACCESS_LENGTH_TYPE", "TYPE" => "char"), "GROUP_ACTIVE" => array("FIELD" => "G.ACTIVE", "TYPE" => "char", "FROM" => "INNER JOIN b_group G ON (CPG.GROUP_ID = G.ID)"), "GROUP_NAME" => array("FIELD" => "G.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_group G ON (CPG.GROUP_ID = G.ID)"));
$arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && empty($arGroupBy)) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_catalog_product2group CPG " . "\t" . $arSqls["FROM"] . " ";
if (!empty($arSqls["WHERE"])) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (!empty($arSqls["GROUPBY"])) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_catalog_product2group CPG " . "\t" . $arSqls["FROM"] . " ";
if (!empty($arSqls["WHERE"])) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (!empty($arSqls["GROUPBY"])) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (!empty($arSqls["ORDERBY"])) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_catalog_product2group CPG " . "\t" . $arSqls["FROM"] . " ";
if (!empty($arSqls["WHERE"])) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (!empty($arSqls["GROUPBY"])) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (empty($arSqls["GROUPBY"])) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例5: getList
static function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
$arFields = array("ID" => array("FIELD" => "DE.ID", "TYPE" => "int"), "DOC_ID" => array("FIELD" => "DE.DOC_ID", "TYPE" => "int"), "STORE_FROM" => array("FIELD" => "DE.STORE_FROM", "TYPE" => "int"), "STORE_TO" => array("FIELD" => "DE.STORE_TO", "TYPE" => "int"), "ELEMENT_ID" => array("FIELD" => "DE.ELEMENT_ID", "TYPE" => "int"), "AMOUNT" => array("FIELD" => "DE.AMOUNT", "TYPE" => "double"), "PURCHASING_PRICE" => array("FIELD" => "DE.PURCHASING_PRICE", "TYPE" => "double"), "IS_MULTIPLY_BARCODE" => array("FIELD" => "CP.BARCODE_MULTI", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_product CP ON (DE.ELEMENT_ID = CP.ID)"));
$arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_catalog_docs_element DE " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return false;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_catalog_docs_element DE " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_catalog_docs_element DE " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && intval($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . intval($arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例6: GetList
public static function GetList($arOrder = array("ID" => "ASC"), $arFilter = array(), $arAddParams = array())
{
global $DB;
$arFields = array("ID" => array("FIELD" => "BPP.ID", "TYPE" => "int"), "POST_ID" => array("FIELD" => "BPP.POST_ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "BPP.USER_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "BPP.NAME", "TYPE" => "string"), "VALUE" => array("FIELD" => "BPP.VALUE", "TYPE" => "string"), "RANK" => $arOrder["OWNER_ID"] > 0 ? array("FIELD" => "RV0.RANK", "TYPE" => "int", "FROM" => "\n\tLEFT JOIN (\n\t\t" . "SELECT MAX(RV2.VOTE_WEIGHT) as VOTE_WEIGHT, RV2.ENTITY_ID \n\t\t" . "FROM b_rating_user RV2 \n\t\t" . "GROUP BY RV2.ENTITY_ID) RV ON (RV.ENTITY_ID = BPP.USER_ID)\n\t" . "LEFT JOIN (\n\t\t" . "SELECT RV1.OWNER_ID, SUM(case when RV1.ID is not null then 1 else 0 end) as RANK \n\t\t" . "FROM b_rating_vote RV1 \n\t\t" . "WHERE RV1.USER_ID = " . $arOrder["OWNER_ID"] . "\n\t\t" . "GROUP BY RV1.OWNER_ID) RV0 ON (RV0.OWNER_ID = BPP.USER_ID)") : array("FIELD" => "RV.RANK", "TYPE" => "string", "FROM" => "\n\tLEFT JOIN (" . "\n\t\tSELECT MAX(RV2.VOTE_WEIGHT) as VOTE_WEIGHT, RV2.ENTITY_ID, 0 as RANK " . "\n\t\tFROM b_rating_user RV2" . "\n\t\tGROUP BY RV2.ENTITY_ID) RV ON (RV.ENTITY_ID = BPP.USER_ID)"), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_SECOND_NAME" => array("FIELD" => "U.SECOND_NAME", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"), "USER_PERSONAL_PHOTO" => array("FIELD" => "U.PERSONAL_PHOTO", "TYPE" => "string", "FROM" => "\n\tINNER JOIN b_user U ON (BPP.USER_ID = U.ID)"));
$arSelect = array_diff(array_keys($arFields), array("RANK"));
$arSelect = is_array($arAddParams["SELECT"]) && !empty($arAddParams["SELECT"]) ? array_intersect($arAddParams["SELECT"], $arSelect) : $arSelect;
$arSql = CBlog::PrepareSql($arFields, array(), $arFilter, false, $arSelect);
$arSql["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSql["SELECT"]);
$iCnt = 0;
if ($arAddParams["bCount"] || array_key_exists("bDescPageNumbering", $arAddParams)) {
$strSql = "SELECT COUNT(BPP.ID) AS CNT \n" . "FROM b_blog_post_param BPP " . $arSql["FROM"] . "\n" . (empty($arSql["GROUPBY"]) ? "" : "GROUP BY " . $arSql["GROUPBY"] . "\n") . "WHERE " . (empty($arSql["WHERE"]) ? "1 = 1" : $arSql["WHERE"]);
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arAddParams["bCount"]) {
return $db_res;
}
$iCnt = $db_res && ($res = $db_res->Fetch()) ? intval($res["CNT"]) : 0;
}
// ORDER BY -->
$arSqlOrder = array();
foreach ($arOrder as $by => $order) {
$by = strtoupper($by);
$order = strtoupper($order) != "ASC" ? "DESC" : "ASK";
if (array_key_exists($by, $arFields) && !array_key_exists($by, $arSqlOrder)) {
if (strtoupper($DB->type) == "ORACLE") {
$order .= $order == "ASC" ? " NULLS FIRST" : " NULLS LAST";
}
if (isset($arFields[$by]["FROM"]) && !empty($arFields[$by]["FROM"]) && strpos($arSql["FROM"], $arFields[$by]["FROM"]) === false) {
$arSql["FROM"] .= " " . $arFields[$by]["FROM"];
}
if ($by == "RANK") {
$arSql["SELECT"] .= ", " . $arFields["RANK"]["FIELD"];
$arSqlOrder[$by] = IsModuleInstalled("intranet") ? "RV.VOTE_WEIGHT " . $order . ", RANK " . $order : "RANK " . $order . ", RV.VOTE_WEIGHT " . $order;
} else {
$arSqlOrder[$by] = (array_key_exists("ORDER", $arFields[$by]) ? $arFields[$by]["ORDER"] : $arFields[$by]["FIELD"]) . " " . $order;
}
}
}
DelDuplicateSort($arSqlOrder);
$arSql["ORDERBY"] = implode(", ", $arSqlOrder);
// <-- ORDER BY
$strSql = "SELECT " . $arSql["SELECT"] . "\n" . "FROM b_blog_post_param BPP" . $arSql["FROM"] . "\n" . "WHERE " . (empty($arSql["WHERE"]) ? "1 = 1" : $arSql["WHERE"]) . (empty($arSql["ORDERBY"]) ? "" : "\nORDER BY " . $arSql["ORDERBY"]);
if (is_set($arAddParams, "bDescPageNumbering")) {
$db_res = new CDBResult();
$db_res->NavQuery($strSql, $iCnt, $arAddParams);
} else {
$db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $db_res;
}
示例7: GetMessagesUsers
function GetMessagesUsers($userID, $arNavStartParams = false, $online_interval = 120)
{
global $DB;
$userID = IntVal($userID);
if ($userID <= 0) {
return false;
}
$strSql = "SELECT U.ID, U.ACTIVE, U.LOGIN, U.NAME, U.LAST_NAME, U.SECOND_NAME, U.PERSONAL_PHOTO, U.PERSONAL_GENDER, COUNT(M.ID) as TOTAL, MAX(M.DATE_CREATE) as MAX_DATE, " . "\tIF(U.LAST_ACTIVITY_DATE > DATE_SUB(NOW(), INTERVAL " . intval($online_interval) . " SECOND), 'Y', 'N') IS_ONLINE, " . "\t" . $DB->DateToCharFunction("MAX(M.DATE_CREATE)", "FULL") . " as MAX_DATE_FORMAT, " . "\tSUM(CASE WHEN M.DATE_VIEW IS NULL AND M.TO_USER_ID = " . $userID . " THEN 1 ELSE 0 END) as UNREAD " . "FROM b_user U, b_sonet_messages M " . "WHERE " . "\t(M.IS_LOG IS NULL OR NOT M.IS_LOG = 'Y') " . "\tAND ( " . "\tM.TO_USER_ID = " . $userID . " " . "\tAND M.FROM_USER_ID = U.ID " . "\tAND M.TO_DELETED = 'N' " . "\tOR " . "\tM.FROM_USER_ID = " . $userID . " " . "\tAND M.TO_USER_ID = U.ID " . "\tAND M.FROM_DELETED = 'N' " . "\t) " . "GROUP BY U.ID, U.NAME, U.LAST_NAME, U.SECOND_NAME, U.PERSONAL_PHOTO, U.PERSONAL_GENDER " . "ORDER BY UNREAD DESC, MAX_DATE DESC ";
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT DISTINCT FROM_USER_ID " . "FROM b_sonet_messages M " . "WHERE " . "(M.IS_LOG IS NULL OR NOT M.IS_LOG = 'Y') " . "AND M.TO_USER_ID = " . $userID . " " . "AND M.TO_DELETED = 'N' " . "UNION DISTINCT " . "SELECT DISTINCT TO_USER_ID " . "FROM b_sonet_messages " . "WHERE " . "(IS_LOG IS NULL OR NOT IS_LOG = 'Y') " . "AND FROM_USER_ID = " . $userID . " " . "AND FROM_DELETED = 'N'";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if ($dbRes) {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例8: GetList
//.........这里部分代码省略.........
* array("SORT" => "ASC"),
* array("PERSON_TYPE_ID" => $PERSON_TYPE),
* false,
* false,
* array()
* );
*
* while ($propsGroup = $db_propsGroup->Fetch())
* {
* echo $propsGroup["NAME"]."<br>";
* }
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleorderpropsgroup/csaleorderpropsgroup__getlist.7a3426ca.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
// To call the old form
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "PG.ID", "TYPE" => "int"), "PERSON_TYPE_ID" => array("FIELD" => "PG.PERSON_TYPE_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "PG.NAME", "TYPE" => "string"), "SORT" => array("FIELD" => "PG.SORT", "TYPE" => "int"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props_group PG " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props_group PG " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_order_props_group PG " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例9: GetList
function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION");
}
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "PERSON_TYPE_ID" => array("FIELD" => "P.PERSON_TYPE_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "P.NAME", "TYPE" => "string"), "TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string"), "REQUIED" => array("FIELD" => "P.REQUIED", "TYPE" => "char"), "REQUIRED" => array("FIELD" => "P.REQUIED", "TYPE" => "char"), "DEFAULT_VALUE" => array("FIELD" => "P.DEFAULT_VALUE", "TYPE" => "string"), "SORT" => array("FIELD" => "P.SORT", "TYPE" => "int"), "USER_PROPS" => array("FIELD" => "P.USER_PROPS", "TYPE" => "char"), "IS_LOCATION" => array("FIELD" => "P.IS_LOCATION", "TYPE" => "char"), "PROPS_GROUP_ID" => array("FIELD" => "P.PROPS_GROUP_ID", "TYPE" => "int"), "SIZE1" => array("FIELD" => "P.SIZE1", "TYPE" => "int"), "SIZE2" => array("FIELD" => "P.SIZE2", "TYPE" => "int"), "DESCRIPTION" => array("FIELD" => "P.DESCRIPTION", "TYPE" => "string"), "IS_EMAIL" => array("FIELD" => "P.IS_EMAIL", "TYPE" => "char"), "IS_PROFILE_NAME" => array("FIELD" => "P.IS_PROFILE_NAME", "TYPE" => "char"), "IS_PAYER" => array("FIELD" => "P.IS_PAYER", "TYPE" => "char"), "IS_LOCATION4TAX" => array("FIELD" => "P.IS_LOCATION4TAX", "TYPE" => "char"), "IS_FILTERED" => array("FIELD" => "P.IS_FILTERED", "TYPE" => "char"), "IS_ZIP" => array("FIELD" => "P.IS_ZIP", "TYPE" => "char"), "CODE" => array("FIELD" => "P.CODE", "TYPE" => "string"), "ACTIVE" => array("FIELD" => "P.ACTIVE", "TYPE" => "char"), "UTIL" => array("FIELD" => "P.UTIL", "TYPE" => "char"), "INPUT_FIELD_LOCATION" => array("FIELD" => "P.INPUT_FIELD_LOCATION", "TYPE" => "int"), "GROUP_ID" => array("FIELD" => "PG.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_PERSON_TYPE_ID" => array("FIELD" => "PG.PERSON_TYPE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_NAME" => array("FIELD" => "PG.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_SORT" => array("FIELD" => "PG.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "PERSON_TYPE_LID" => array("FIELD" => "SPT.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_NAME" => array("FIELD" => "SPT.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_SORT" => array("FIELD" => "SPT.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_ACTIVE" => array("FIELD" => "SPT.ACTIVE", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_order_props P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例10: GetList
//.........这里部分代码省略.........
$arSqlSearch[] = "S.DATE_UPDATE<=" . $DB->CharToDateFunction($val . " 23:59:59");
break;
case "INSERT_1":
$arSqlSearch[] = "S.DATE_INSERT>=" . $DB->CharToDateFunction($val);
break;
case "INSERT_2":
$arSqlSearch[] = "S.DATE_INSERT<=" . $DB->CharToDateFunction($val . " 23:59:59");
break;
case "USER":
$arSqlSearch[] = GetFilterQuery("U.ID, U.LOGIN, U.NAME, U.LAST_NAME", $val);
break;
case "USER_ID":
$arSqlSearch[] = GetFilterQuery("S.USER_ID", $val, "N");
break;
case "ANONYMOUS":
$arSqlSearch[] = $val == "Y" ? "(S.USER_ID = 0 or S.USER_ID is null)" : "(S.USER_ID > 0 and S.USER_ID is not null)";
break;
case "CONFIRMED":
$arSqlSearch[] = $val == "Y" ? "S.CONFIRMED='Y'" : "S.CONFIRMED='N'";
break;
case "ACTIVE":
$arSqlSearch[] = $val == "Y" ? "S.ACTIVE='Y'" : "S.ACTIVE='N'";
break;
case "FORMAT":
$arSqlSearch[] = $val == "text" ? "S.FORMAT='text'" : "S.FORMAT='html'";
break;
case "RUBRIC":
case "RUBRIC_MULTI":
case "DISTRIBUTION":
if (is_array($val)) {
$val = implode(" | ", $val);
}
if (strlen($val) > 0) {
$from1 = " INNER JOIN b_subscription_rubric SR ON (SR.SUBSCRIPTION_ID=S.ID) ";
$arSqlSearch[] = GetFilterQuery("SR.LIST_RUBRIC_ID", $val, "N");
} else {
$arSqlSearch[] = " 1=0 ";
}
break;
}
}
}
$strSqlSearch = GetFilterSqlSearch($arSqlSearch);
$arOrder = array();
foreach ($aSort as $by => $ord) {
$by = strtoupper($by);
$ord = strtoupper($ord) != "ASC" ? "DESC" : "ASC";
switch ($by) {
case "ID":
$arOrder[$by] = "S.ID " . $ord;
break;
case "DATE_INSERT":
$arOrder[$by] = "S.DATE_INSERT " . $ord;
break;
case "DATE_UPDATE":
$arOrder[$by] = "S.DATE_UPDATE " . $ord;
break;
case "DATE_CONFIRM":
$arOrder[$by] = "S.DATE_CONFIRM " . $ord;
break;
case "ACT":
$arOrder[$by] = "S.ACTIVE " . $ord;
break;
case "CONF":
$arOrder[$by] = "S.CONFIRMED " . $ord;
break;
case "EMAIL":
$arOrder[$by] = "S.EMAIL " . $ord;
break;
case "FMT":
$arOrder[$by] = "S.FORMAT " . $ord;
break;
case "USER":
$arOrder[$by] = "S.USER_ID " . $ord;
break;
case "CONFIRM_CODE":
$arOrder[$by] = "S.CONFIRM_CODE " . $ord;
break;
}
}
if (count($arOrder) <= 0) {
$arOrder["ID"] = "S.ID DESC";
}
if (is_array($arNavStartParams)) {
$strSql = "\n\t\t\t\tSELECT count(" . ($from1 != "" ? "DISTINCT S.ID" : "'x'") . ") as C\n\t\t\t\tFROM\n\t\t\t\t\tb_subscription S\n\t\t\t\t\tLEFT JOIN b_user U ON (S.USER_ID=U.ID)\n\t\t\t\t\t{$from1}\n\t\t\t\tWHERE\n\t\t\t\t" . $strSqlSearch;
$res_cnt = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$res_cnt = $res_cnt->Fetch();
$cnt = $res_cnt["C"];
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tS.ID, S.USER_ID, S.ACTIVE, S.EMAIL, S.FORMAT, S.CONFIRM_CODE, S.CONFIRMED,\n\t\t\t\t\t" . $DB->DateToCharFunction("S.DATE_UPDATE") . " DATE_UPDATE,\n\t\t\t\t\t" . $DB->DateToCharFunction("S.DATE_INSERT") . " DATE_INSERT,\n\t\t\t\t\t" . $DB->DateToCharFunction("S.DATE_CONFIRM") . " DATE_CONFIRM,\n\t\t\t\t\tU.LOGIN USER_LOGIN,\n\t\t\t\t\tU.NAME USER_NAME,\n\t\t\t\t\tU.LAST_NAME USER_LAST_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_subscription S\n\t\t\t\t\tLEFT JOIN b_user U ON (S.USER_ID=U.ID)\n\t\t\t\t\t{$from1}\n\t\t\t\tWHERE\n\t\t\t\t{$strSqlSearch}\n\t\t\t\t" . ($from1 != "" ? "GROUP BY S.ID, S.USER_ID, S.ACTIVE, S.EMAIL, S.FORMAT, S.CONFIRM_CODE, S.CONFIRMED, S.DATE_CONFIRM, S.DATE_UPDATE, S.DATE_INSERT, U.LOGIN, U.NAME, U.LAST_NAME" : "") . "\n\t\t\t\tORDER BY " . implode(", ", $arOrder);
$res = new CDBResult();
$res->NavQuery($strSql, $cnt, $arNavStartParams);
$res->is_filtered = IsFiltered($strSqlSearch);
return $res;
} else {
$strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tS.ID, S.USER_ID, S.ACTIVE, S.EMAIL, S.FORMAT, S.CONFIRM_CODE, S.CONFIRMED,\n\t\t\t\t\t" . $DB->DateToCharFunction("S.DATE_UPDATE") . " DATE_UPDATE,\n\t\t\t\t\t" . $DB->DateToCharFunction("S.DATE_INSERT") . " DATE_INSERT,\n\t\t\t\t\t" . $DB->DateToCharFunction("S.DATE_CONFIRM") . " DATE_CONFIRM,\n\t\t\t\t\tU.LOGIN USER_LOGIN,\n\t\t\t\t\tU.NAME USER_NAME,\n\t\t\t\t\tU.LAST_NAME USER_LAST_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_subscription S\n\t\t\t\t\tLEFT JOIN b_user U ON (S.USER_ID=U.ID)\n\t\t\t\t\t{$from1}\n\t\t\t\tWHERE\n\t\t\t\t{$strSqlSearch}\n\t\t\t\t" . ($from1 != "" ? "GROUP BY S.ID, S.USER_ID, S.ACTIVE, S.EMAIL, S.FORMAT, S.CONFIRM_CODE, S.CONFIRMED, S.DATE_CONFIRM, S.DATE_UPDATE, S.DATE_INSERT, U.LOGIN, U.NAME, U.LAST_NAME" : "") . "\n\t\t\t\tORDER BY " . implode(", ", $arOrder);
$res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$res->is_filtered = IsFiltered($strSqlSearch);
return $res;
}
}
示例11: GetHistoryList
/**
* The function select order history
*
* @param array $arOrder - array to sort
* @param array $arFilter - array to filter
* @param array $arGroupBy - array to group records
* @param array $arNavStartParams - array to parameters
* @param array $arSelectFields - array to selectes fields
* @return object $dbRes - object result
*/
public function GetHistoryList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (array_key_exists("H_DATE_INSERT_FROM", $arFilter)) {
$val = $arFilter["H_DATE_INSERT_FROM"];
unset($arFilter["H_DATE_INSERT_FROM"]);
$arFilter[">=H_DATE_INSERT"] = $val;
}
if (array_key_exists("H_DATE_INSERT_TO", $arFilter)) {
$val = $arFilter["H_DATE_INSERT_TO"];
unset($arFilter["H_DATE_INSERT_TO"]);
$arFilter["<=H_DATE_INSERT"] = $val;
}
if (!$arSelectFields || count($arSelectFields) <= 0 || in_array("*", $arSelectFields)) {
$arSelectFields = array("ID", "H_USER_ID", "H_DATE_INSERT", "H_ORDER_ID", "H_CURRENCY", "PERSON_TYPE_ID", "PAYED", "DATE_PAYED", "EMP_PAYED_ID", "CANCELED", "DATE_CANCELED", "REASON_CANCELED", "MARKED", "DATE_MARKED", "REASON_MARKED", "DEDUCTED", "DATE_DEDUCTED", "REASON_UNDO_DEDUCTED", "STATUS_ID", "DATE_STATUS", "PRICE_DELIVERY", "ALLOW_DELIVERY", "DATE_ALLOW_DELIVERY", "PRICE", "CURRENCY", "DISCOUNT_VALUE", "USER_ID", "PAY_SYSTEM_ID", "DELIVERY_ID", "PS_STATUS", "PS_STATUS_CODE", "PS_STATUS_DESCRIPTION", "PS_STATUS_MESSAGE", "PS_SUM", "PS_CURRENCY", "PS_RESPONSE_DATE", "TAX_VALUE", "STAT_GID", "SUM_PAID", "PAY_VOUCHER_NUM", "PAY_VOUCHER_DATE", "AFFILIATE_ID", "DELIVERY_DOC_NUM", "DELIVERY_DOC_DATE");
}
$arFields = array("ID" => array("FIELD" => "V.ID", "TYPE" => "int"), "H_ORDER_ID" => array("FIELD" => "V.H_ORDER_ID", "TYPE" => "int"), "H_USER_ID" => array("FIELD" => "V.H_USER_ID", "TYPE" => "int"), "H_DATE_INSERT" => array("FIELD" => "V.H_DATE_INSERT", "TYPE" => "datetime"), "H_CURRENCY" => array("FIELD" => "V.H_CURRENCY", "TYPE" => "string"), "PERSON_TYPE_ID" => array("FIELD" => "V.PERSON_TYPE_ID", "TYPE" => "int"), "PAYED" => array("FIELD" => "V.PAYED", "TYPE" => "char"), "DATE_PAYED" => array("FIELD" => "V.DATE_PAYED", "TYPE" => "datetime"), "EMP_PAYED_ID" => array("FIELD" => "V.EMP_PAYED_ID", "TYPE" => "int"), "CANCELED" => array("FIELD" => "V.CANCELED", "TYPE" => "char"), "DATE_CANCELED" => array("FIELD" => "V.DATE_CANCELED", "TYPE" => "datetime"), "REASON_CANCELED" => array("FIELD" => "V.REASON_CANCELED", "TYPE" => "string"), "MARKED" => array("FIELD" => "V.MARKED", "TYPE" => "char"), "DATE_MARKED" => array("FIELD" => "V.DATE_MARKED", "TYPE" => "datetime"), "REASON_MARKED" => array("FIELD" => "V.REASON_MARKED", "TYPE" => "string"), "DEDUCTED" => array("FIELD" => "V.DEDUCTED", "TYPE" => "char"), "DATE_DEDUCTED" => array("FIELD" => "V.DATE_DEDUCTED", "TYPE" => "datetime"), "REASON_DEDUCTED" => array("FIELD" => "V.REASON_UNDO_DEDUCTED", "TYPE" => "string"), "STATUS_ID" => array("FIELD" => "V.STATUS_ID", "TYPE" => "char"), "DATE_STATUS" => array("FIELD" => "V.DATE_STATUS", "TYPE" => "datetime"), "PAY_VOUCHER_NUM" => array("FIELD" => "V.PAY_VOUCHER_NUM", "TYPE" => "string"), "PAY_VOUCHER_DATE" => array("FIELD" => "V.PAY_VOUCHER_DATE", "TYPE" => "date"), "PRICE_DELIVERY" => array("FIELD" => "V.PRICE_DELIVERY", "TYPE" => "double"), "ALLOW_DELIVERY" => array("FIELD" => "V.ALLOW_DELIVERY", "TYPE" => "char"), "DATE_ALLOW_DELIVERY" => array("FIELD" => "V.DATE_ALLOW_DELIVERY", "TYPE" => "datetime"), "PRICE" => array("FIELD" => "V.PRICE", "TYPE" => "double"), "CURRENCY" => array("FIELD" => "V.CURRENCY", "TYPE" => "string"), "DISCOUNT_VALUE" => array("FIELD" => "V.DISCOUNT_VALUE", "TYPE" => "double"), "SUM_PAID" => array("FIELD" => "V.SUM_PAID", "TYPE" => "double"), "USER_ID" => array("FIELD" => "V.USER_ID", "TYPE" => "int"), "PAY_SYSTEM_ID" => array("FIELD" => "V.PAY_SYSTEM_ID", "TYPE" => "int"), "DELIVERY_ID" => array("FIELD" => "V.DELIVERY_ID", "TYPE" => "string"), "PS_STATUS" => array("FIELD" => "V.PS_STATUS", "TYPE" => "char"), "PS_STATUS_CODE" => array("FIELD" => "V.PS_STATUS_CODE", "TYPE" => "string"), "PS_STATUS_DESCRIPTION" => array("FIELD" => "V.PS_STATUS_DESCRIPTION", "TYPE" => "string"), "PS_STATUS_MESSAGE" => array("FIELD" => "V.PS_STATUS_MESSAGE", "TYPE" => "string"), "PS_SUM" => array("FIELD" => "V.PS_SUM", "TYPE" => "double"), "PS_CURRENCY" => array("FIELD" => "V.PS_CURRENCY", "TYPE" => "string"), "PS_RESPONSE_DATE" => array("FIELD" => "V.PS_RESPONSE_DATE", "TYPE" => "datetime"), "TAX_VALUE" => array("FIELD" => "V.TAX_VALUE", "TYPE" => "double"), "AFFILIATE_ID" => array("FIELD" => "V.AFFILIATE_ID", "TYPE" => "int"), "DELIVERY_DOC_NUM" => array("FIELD" => "V.DELIVERY_DOC_NUM", "TYPE" => "string"), "DELIVERY_DOC_DATE" => array("FIELD" => "V.DELIVERY_DOC_DATE", "TYPE" => "date"));
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
$strSql = "SELECT " . $arSqls["SELECT"] . " FROM b_sale_order_history V ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return false;
}
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT FROM b_sale_order_history B ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
$strSql = $DB->TopSql($strSql, $arNavStartParams["nTopCount"]);
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例12: PrepareFromQueryData
public static function PrepareFromQueryData(array $arSql, $tableName, $tableAlias, $dbType, $arNavStartParams = false)
{
global $DB;
$sql = 'SELECT ' . $arSql['SELECT'] . ' FROM ' . $tableName . ' ' . $tableAlias . ' ' . $arSql['FROM'] . ' GROUP BY ' . $arSql['GROUPBY'] . ' ORDER BY ' . $arSql['ORDERBY'];
$enableNavigation = is_array($arNavStartParams);
$top = $enableNavigation && isset($arNavStartParams['nTopCount']) ? (int) $arNavStartParams['nTopCount'] : 0;
if ($enableNavigation && $top <= 0) {
if (COption::GetOptionString('crm', 'enable_rough_row_count', 'Y') === 'Y') {
$cnt = self::GetRoughRowCount($arSql, $tableName, $tableAlias, $dbType);
} else {
$cnt = CSqlUtil::GetRowCount($arSql, $tableName, $tableAlias, $dbType);
}
$dbResult = new CDBResult();
$dbResult->NavQuery($sql, $cnt, $arNavStartParams);
return $dbResult;
}
if ($enableNavigation && $top > 0) {
CSqlUtil::PrepareSelectTop($sql, $top, $dbType);
}
$dbResult = $DB->Query($sql, false, 'File: ' . __FILE__ . '<br/>Line: ' . __LINE__);
return $dbResult;
}
示例13: GetList
//.........这里部分代码省略.........
else
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
$r = $obUserFieldsSql->GetFilter();
if(strlen($r)>0)
$strSqlUFFilter = " (".$r.") ";
if (is_array($arGroupBy) && count($arGroupBy)==0)
{
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
$obUserFieldsSql->GetSelect()." ".
"FROM b_blog_comment C ".
" ".$arSqls["FROM"]." ".
$obUserFieldsSql->GetJoin("C.ID")." ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
if(strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUFFilter) > 0)
$strSql .= " AND ".$strSqlUFFilter." ";
elseif(strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUFFilter) > 0)
$strSql .= " WHERE ".$strSqlUFFilter." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
return $arRes["CNT"];
else
return False;
}
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
$obUserFieldsSql->GetSelect()." ".
"FROM b_blog_comment C ".
" ".$arSqls["FROM"]." ".
$obUserFieldsSql->GetJoin("C.ID")." ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
if(strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUFFilter) > 0)
$strSql .= " AND ".$strSqlUFFilter." ";
elseif(strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUFFilter) > 0)
$strSql .= " WHERE ".$strSqlUFFilter." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
if (strlen($arSqls["ORDERBY"]) > 0)
$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"])<=0)
{
$strSql_tmp =
"SELECT COUNT('x') as CNT ".
$obUserFieldsSql->GetSelect()." ".
"FROM b_blog_comment C ".
" ".$arSqls["FROM"]." ".
$obUserFieldsSql->GetJoin("C.ID")." ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql_tmp .= "WHERE ".$arSqls["WHERE"]." ";
if(strlen($arSqls["WHERE"]) > 0 && strlen($strSqlUFFilter) > 0)
$strSql_tmp .= " AND ".$strSqlUFFilter." ";
elseif(strlen($arSqls["WHERE"]) <= 0 && strlen($strSqlUFFilter) > 0)
$strSql_tmp .= " WHERE ".$strSqlUFFilter." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0)
{
if ($arRes = $dbRes->Fetch())
$cnt = $arRes["CNT"];
}
else
{
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_POST"));
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
}
else
{
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0)
$strSql .= "LIMIT ".IntVal($arNavStartParams["nTopCount"]);
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$dbRes->SetUserFields($USER_FIELD_MANAGER->GetUserFields("BLOG_POST"));
}
return $dbRes;
}
示例14: GetListEx
function GetListEx($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (empty($arSelectFields)) {
$arSelectFields = array("ID", "NAME", "BASE", "SORT", "NAME_LANG", "XML_ID", "MODIFIED_BY", "CREATED_BY", "DATE_CREATE", "TIMESTAMP_X");
}
$arFields = array("ID" => array("FIELD" => "CG.ID", "TYPE" => "int"), "NAME" => array("FIELD" => "CG.NAME", "TYPE" => "string"), "BASE" => array("FIELD" => "CG.BASE", "TYPE" => "char"), "SORT" => array("FIELD" => "CG.SORT", "TYPE" => "int"), "XML_ID" => array("FIELD" => "CG.XML_ID", "TYPE" => "string"), "TIMESTAMP_X" => array("FIELD" => "CG.TIMESTAMP_X", "TYPE" => "datetime"), "MODIFIED_BY" => array("FIELD" => "CG.MODIFIED_BY", "TYPE" => "int"), "DATE_CREATE" => array("FIELD" => "CG.DATE_CREATE", "TYPE" => "datetime"), "CREATED_BY" => array("FIELD" => "CG.CREATED_BY", "TYPE" => "int"), "GROUP_ID" => array("FIELD" => "CG2G.ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_group2group CG2G ON (CG.ID = CG2G.CATALOG_GROUP_ID)"), "GROUP_CATALOG_GROUP_ID" => array("FIELD" => "CG2G.CATALOG_GROUP_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_group2group CG2G ON (CG.ID = CG2G.CATALOG_GROUP_ID)"), "GROUP_GROUP_ID" => array("FIELD" => "CG2G.GROUP_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_group2group CG2G ON (CG.ID = CG2G.CATALOG_GROUP_ID)"), "GROUP_BUY" => array("FIELD" => "CG2G.BUY", "TYPE" => "char", "FROM" => "INNER JOIN b_catalog_group2group CG2G ON (CG.ID = CG2G.CATALOG_GROUP_ID)"), "NAME_LANG" => array("FIELD" => "CGL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_catalog_group_lang CGL ON (CG.ID = CGL.CATALOG_GROUP_ID AND CGL.LANG = '" . LANGUAGE_ID . "')"));
$arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (empty($arGroupBy) && is_array($arGroupBy)) {
$strSql = "SELECT " . $arSqls["SELECT"] . " FROM b_catalog_group CG " . $arSqls["FROM"];
if (!empty($arSqls["WHERE"])) {
$strSql .= " WHERE " . $arSqls["WHERE"];
}
if (!empty($arSqls["GROUPBY"])) {
$strSql .= " GROUP BY " . $arSqls["GROUPBY"];
}
if (!empty($arSqls["HAVING"])) {
$strSql .= " HAVING " . $arSqls["HAVING"];
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return false;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " FROM b_catalog_group CG " . $arSqls["FROM"];
if (!empty($arSqls["WHERE"])) {
$strSql .= " WHERE " . $arSqls["WHERE"];
}
if (!empty($arSqls["GROUPBY"])) {
$strSql .= " GROUP BY " . $arSqls["GROUPBY"];
}
if (!empty($arSqls["HAVING"])) {
$strSql .= " HAVING " . $arSqls["HAVING"];
}
if (!empty($arSqls["ORDERBY"])) {
$strSql .= " ORDER BY " . $arSqls["ORDERBY"];
}
$intTopCount = 0;
$boolNavStartParams = !empty($arNavStartParams) && is_array($arNavStartParams);
if ($boolNavStartParams && array_key_exists('nTopCount', $arNavStartParams)) {
$intTopCount = intval($arNavStartParams["nTopCount"]);
}
if ($boolNavStartParams && 0 >= $intTopCount) {
$strSql_tmp = "SELECT COUNT('x') as CNT FROM b_catalog_group CG " . $arSqls["FROM"];
if (!empty($arSqls["WHERE"])) {
$strSql_tmp .= " WHERE " . $arSqls["WHERE"];
}
if (!empty($arSqls["GROUPBY"])) {
$strSql_tmp .= " GROUP BY " . $arSqls["GROUPBY"];
}
if (!empty($arSqls["HAVING"])) {
$strSql_tmp .= " HAVING " . $arSqls["HAVING"];
}
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (empty($arSqls["GROUPBY"])) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if ($boolNavStartParams && 0 < $intTopCount) {
$strSql .= " LIMIT " . $intTopCount;
}
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例15: GetList
//.........这里部分代码省略.........
* false,
* array("CURRENT_BUDGET", "CURRENCY")
* );
* while ($arAccountCurrency = $dbAccountCurrency->Fetch())
* {
* echo "На счете ".$arAccountCurrency["CURRENCY"].": ";
* echo SaleFormatCurrency($arAccountCurrency["CURRENT_BUDGET"],
* $arAccountCurrency["CURRENCY"])."<br>";
* }
*
* // Выберем, сумму счетов покупателей (сколько должен магазин покупателям)
* $dbAccountCurrency = CSaleUserAccount::GetList(
* array("CURRENCY" => "ASC"),
* array(),
* array("CURRENCY", "SUM" => "CURRENT_BUDGET"),
* false,
* array("CURRENCY", "SUM" => "CURRENT_BUDGET")
* );
* while ($arAccountCurrency = $dbAccountCurrency->Fetch())
* {
* echo "В валюте ".$arAccountCurrency["CURRENCY"].": ";
* echo SaleFormatCurrency($arAccountCurrency["CURRENT_BUDGET"],
* $arAccountCurrency["CURRENCY"])."<br>";
* }
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleuseraccount/csaleuseraccount.getlist.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "USER_ID", "CURRENT_BUDGET", "CURRENCY", "LOCKED", "NOTES", "TIMESTAMP_X", "DATE_LOCKED");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "UA.ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "UA.USER_ID", "TYPE" => "int"), "CURRENT_BUDGET" => array("FIELD" => "UA.CURRENT_BUDGET", "TYPE" => "double"), "CURRENCY" => array("FIELD" => "UA.CURRENCY", "TYPE" => "string"), "LOCKED" => array("FIELD" => "UA.LOCKED", "TYPE" => "char"), "NOTES" => array("FIELD" => "UA.NOTES", "TYPE" => "string"), "TIMESTAMP_X" => array("FIELD" => "UA.TIMESTAMP_X", "TYPE" => "datetime"), "DATE_LOCKED" => array("FIELD" => "UA.DATE_LOCKED", "TYPE" => "datetime"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "char", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_USER" => array("FIELD" => "U.LOGIN,U.NAME,U.LAST_NAME,U.EMAIL,U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_user_account UA " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_user_account UA " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_user_account UA " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}