Пример #1
1
 /** @return \CDBResult */
 public function getData()
 {
     $formId = $this->getFieldValue('FORM', null);
     $propertyNameId = $this->getFieldValue('PROPERTY_NAME', null);
     $propertyEmailId = $this->getFieldValue('PROPERTY_EMAIL', null);
     $formResultsDb = new \CDBResult();
     if ($formId && $propertyEmailId) {
         $dataResult = array();
         $filter = array();
         $formResultDb = \CFormResult::GetList($formId, $by = "s_timestamp", $order = "asc", $filter, $filtered, "N");
         while ($formResult = $formResultDb->Fetch()) {
             $answerList = \CFormResult::GetDataByID($formResult['ID'], array(), $formResult, $answerList2);
             $data = array();
             foreach ($answerList as $fieldCode => $arFieldsAnswer) {
                 if ($arFieldsAnswer[0]['TITLE_TYPE'] == 'text') {
                     if ($arFieldsAnswer[0]['FIELD_ID'] == $propertyNameId) {
                         $data['NAME'] = $arFieldsAnswer[0]['USER_TEXT'];
                     }
                     if ($arFieldsAnswer[0]['FIELD_ID'] == $propertyEmailId) {
                         $data['EMAIL'] = $arFieldsAnswer[0]['USER_TEXT'];
                     }
                 }
             }
             if (!empty($data['EMAIL'])) {
                 if (intval($formResult['USER_ID']) > 0) {
                     $data['USER_ID'] = intval($formResult['USER_ID']);
                 }
                 $dataResult[] = $data;
             }
         }
         $formResultsDb->InitFromArray($dataResult);
     }
     return $formResultsDb;
 }
Пример #2
0
	public static function GetLastByID($ID)
	{
		$DB = CDatabase::GetModuleConnection('statistic');
		$ID = intval($ID);
		if($ID>0)
		{
			$strSql = "
				SELECT
					G.ID,
					G.FAVORITES,
					G.LAST_USER_ID,
					A.ID as LAST_ADV_ID,
					if(to_days(curdate())=to_days(G.LAST_DATE), 'Y', 'N') LAST
				FROM b_stat_guest G
				LEFT JOIN b_stat_adv A ON A.ID = G.LAST_ADV_ID
				WHERE G.ID='$ID'
				";
			$res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}
		else
		{
			$res = new CDBResult;
			$res->InitFromArray(array());
		}
		return $res;
	}
Пример #3
0
 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;
 }
Пример #4
0
	public static function GetAdvGuestHost($ADV_ID, $GUEST_ID, $IP_NUMBER, $BACK="")
	{
		$err_mess = "File: ".__FILE__."<br>Line: ";
		$DB = CDatabase::GetModuleConnection('statistic');
		$ADV_ID = intval($ADV_ID);
		$GID = intval($GUEST_ID);

		$strSql = "
			SELECT
				count(1) ADV_HOSTS,
				".$DB->DateToCharFunction("max(DATE_HOST_HIT)","SHORT")." MAX_DATE_HOST_HIT
			FROM	b_stat_adv_guest
			WHERE	ADV_ID=$ADV_ID and IP_NUMBER='".$DB->ForSQL($IP_NUMBER)."'
			$BACK
		";
		$rsResult=$DB->Query($strSql, false, $err_mess.__LINE__);
		if(!($arHost = $rsResult->Fetch()))
			$arHost = array("ADV_HOSTS"=>0,"MAX_DATE_HOST_HIT"=>false);

		$strSql = "
			SELECT
				count(1) ADV_GUESTS,
				".$DB->DateToCharFunction("max(DATE_GUEST_HIT)","SHORT")." MAX_DATE_GUEST_HIT
			FROM	b_stat_adv_guest
			WHERE	ADV_ID=$ADV_ID and GUEST_ID=$GID
			$BACK
		";
		$rsResult=$DB->Query($strSql, false, $err_mess.__LINE__);
		if(!($arGuest = $rsResult->Fetch()))
			$arGuest = array("ADV_GUESTS"=>0,"MAX_DATE_GUEST_HIT"=>false);

		$rsResult = new CDBResult;
		$rsResult->InitFromArray(array(array_merge($arGuest,$arHost)));
		return $rsResult;
	}
Пример #5
0
 /** @return \CDBResult */
 public function getData()
 {
     $groupId = $this->getFieldValue('GROUP_ID', null);
     $dateRegister = $this->getFieldValue('DATE_REGISTER', null);
     $active = $this->getFieldValue('ACTIVE', null);
     $filter = array();
     if ($groupId) {
         $filter['GROUP_ID'] = $groupId;
     }
     if (strlen($dateRegister) > 0) {
         if (\Bitrix\Main\Type\Date::isCorrect($dateRegister)) {
             $dateRegister = new \Bitrix\Main\Type\Date($dateRegister);
             $filter['><USER.DATE_REGISTER'] = array($dateRegister->toString(), $dateRegister->add('1 DAY')->toString());
         } else {
             $result = new \CDBResult();
             $result->InitFromArray(array());
             return $result;
         }
     }
     if ($active == 'Y') {
         $filter['USER.ACTIVE'] = $active;
     } elseif ($active == 'N') {
         $filter['USER.ACTIVE'] = $active;
     }
     $userDb = \Bitrix\Main\UserGroupTable::getList(array('select' => array('NAME' => 'USER.NAME', 'EMAIL' => 'USER.EMAIL', 'USER_ID'), 'filter' => $filter, 'group' => array('NAME', 'EMAIL', 'USER_ID'), 'order' => array('USER_ID' => 'ASC')));
     return new \CDBResult($userDb);
 }
Пример #6
0
 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"])));
     }
 }
Пример #7
0
	public static function GetDropDown($type="C", $siteID=false, $sla_id=false)
	{
		$err_mess = (CAllTicketDictionary::err_mess())."<br>Function: GetDropDown<br>Line: ";
		global $DB;
		if ($siteID==false || $siteID=="all")
		{
			$siteID = "";
		}
		$arFilter = array("TYPE" => $type, "SITE" => $siteID);
		$v2 = $v3 = null;
		$rs = CTicketDictionary::GetList(($v1="s_dropdown"), $v2, $arFilter, $v3);
		
		$oldFunctionality = COption::GetOptionString( "support", "SUPPORT_OLD_FUNCTIONALITY", "Y" );
		if( intval( $sla_id ) <= 0 || $oldFunctionality != "Y" || ( $type != "C" && $type!="K" && $type!="M" ) ) return $rs;
		
		switch($type)
		{
			case "C": $strSql = "SELECT CATEGORY_ID as DID FROM b_ticket_sla_2_category WHERE SLA_ID=" . intval( $sla_id ); break;
			case "K": $strSql = "SELECT CRITICALITY_ID as DID FROM b_ticket_sla_2_criticality WHERE SLA_ID=" . intval( $sla_id ); break;
			case "M": $strSql = "SELECT MARK_ID as DID FROM b_ticket_sla_2_mark WHERE SLA_ID=" . intval( $sla_id ); break;
		}
		$r = $DB->Query( $strSql, false, $err_mess . __LINE__ );
		while( $a = $r->Fetch() ) $arDID[] = $a["DID"];
		$arRecords = array();
		while( $ar = $rs->Fetch() ) if( is_array( $arDID ) && ( in_array( $ar["ID"], $arDID ) || in_array( 0,$arDID ) ) ) $arRecords[] = $ar;
		
		$rs = new CDBResult;
		$rs->InitFromArray($arRecords);
		
		return $rs;
	}
Пример #8
0
function getList($blockId, $fields, $order, $filers)
{
    $entity_requests_data_class = connectToBlock($blockId);
    $main_query_requests = new Entity\Query($entity_requests_data_class);
    $main_query_requests->setSelect($fields);
    //$main_query_requests->setSelect(array('ID','UF_TITLE'));
    if (!empty($order)) {
        $main_query_requests->setOrder($order);
    }
    if (!empty($filers)) {
        $main_query_requests->setFilter($filers);
        /*$main_query_requests->setFilter(
              array(
                  'UF_NAME'=>'Александр',
              )
          );*/
    }
    $result_requests = $main_query_requests->exec();
    $result_requests = new CDBResult($result_requests);
    $requests = array();
    while ($row_requests = $result_requests->Fetch()) {
        $requests[] = $row_requests;
        //массив выбранных элементов
    }
    return $requests;
}
Пример #9
0
/**
 * Returns HTML multiple "select"
 *
 * @param string $strBoxName Input name
 * @param CDBResult $a DB result with items
 * @param array $arr Selected values
 * @param string $strDetText Empty item text
 * @param bool $strDetText_selected Allow to choose an empty item
 * @param string $size Size attribute
 * @param string $field1 Additional attributes
 * @return string
 */
function SelectBoxM($strBoxName, $a, $arr, $strDetText = "", $strDetText_selected = false, $size = "5", $field1 = "class=\"typeselect\"")
{
    $strReturnBox = "<select " . $field1 . " multiple name=\"" . $strBoxName . "\" id=\"" . $strBoxName . "\" size=\"" . $size . "\">";
    if ($strDetText != '') {
        $strReturnBox = $strReturnBox . "<option ";
        if ($strDetText_selected) {
            $strReturnBox = $strReturnBox . " selected ";
        }
        $strReturnBox = $strReturnBox . " value='NOT_REF'>" . $strDetText . "</option>";
    }
    while ($ar = $a->Fetch()) {
        $reference_id = $ar["REFERENCE_ID"];
        $reference = $ar["REFERENCE"];
        if ($reference_id == '') {
            $reference_id = $ar["reference_id"];
        }
        if ($reference == '') {
            $reference = $ar["reference"];
        }
        $sel = is_array($arr) && in_array($reference_id, $arr) ? "selected" : "";
        $strReturnBox = $strReturnBox . "<option " . $sel;
        $strReturnBox = $strReturnBox . " value=\"" . htmlspecialcharsbx($reference_id) . "\">" . htmlspecialcharsbx($reference) . "</option>";
    }
    return $strReturnBox . "</select>";
}
Пример #10
0
 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;
 }
 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;
 }
Пример #12
0
 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;
 }
Пример #13
0
 /**
  * Convert CDBResult to array.
  *
  */
 public static function CDBResultToArray(CDBResult $CDBResult)
 {
     if ($CDBResult->SelectedRowsCount() == 0) {
         return array();
     }
     $ret = array();
     while ($row = $CDBResult->Fetch()) {
         $ret[] = $row;
     }
     return $ret;
 }
Пример #14
0
 public static function GetList($arOrder = array('CREATED_DATE' => 'DESC'), $arFilter = array(), $arSelect = array(), $nPageTop = false)
 {
     // Fix for #27449
     if (!CModule::IncludeModule('calendar')) {
         $obRes = new CDBResult();
         $obRes->InitFromArray(array());
         return $obRes;
     }
     global $USER;
     $ENTITY_ID = 'CALENDAR_EVENT';
     $arElement = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields($ENTITY_ID, 0, LANGUAGE_ID);
     if ($arElement == false || !isset($arElement['UF_CRM_CAL_EVENT'])) {
         $arFields = array();
         $arFields['ENTITY_ID'] = $ENTITY_ID;
         $arFields['FIELD_NAME'] = 'UF_CRM_CAL_EVENT';
         $arFields['USER_TYPE_ID'] = 'crm';
         $arFields['EDIT_FORM_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME');
         $arFields['LIST_COLUMN_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME');
         $arFields['LIST_FILTER_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME');
         $arFields['SETTINGS']['LEAD'] = 'Y';
         $arFields['SETTINGS']['CONTACT'] = 'Y';
         $arFields['SETTINGS']['COMPANY'] = 'Y';
         $arFields['SETTINGS']['DEAL'] = 'Y';
         $arFields['MULTIPLE'] = 'Y';
         $CAllUserTypeEntity = new CUserTypeEntity();
         $CAllUserTypeEntity->Add($arFields);
     }
     if (isset($arFilter['ENTITY_TYPE']) && isset($arFilter['ENTITY_ID'])) {
         $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']);
         $arFilter['UF_CRM_CAL_EVENT'] = $arFilter['ENTITY_TYPE'] . '_' . $arFilter['ENTITY_ID'];
         unset($arFilter['ENTITY_TYPE'], $arFilter['ENTITY_ID']);
     } else {
         if (!empty($arFilter['ENTITY_TYPE'])) {
             $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']);
             $arFilter['%UF_CRM_CAL_EVENT'] = $arFilter['ENTITY_TYPE'] . '_';
             unset($arFilter['ENTITY_TYPE']);
         } else {
             $arFilter['!=UF_CRM_CAL_EVENT'] = '';
         }
     }
     $arFilter['CAL_TYPE'] = 'user';
     $arFilter['DELETED'] = 'N';
     if (isset($arFilter['OWNER_ID']) && is_array($arFilter['OWNER_ID'])) {
         $arFilter['OWNER_ID'] = current($arFilter['OWNER_ID']);
     }
     $arCal = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => false, 'userId' => $USER->GetID(), 'fetchAttendees' => false, 'fetchMeetings' => true));
     $obRes = new CDBResult();
     $obRes->InitFromArray($arCal);
     return $obRes;
 }
Пример #15
0
 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;
 }
Пример #16
0
 /**
  * Gets array with one row of selected data.
  * Calls CDBResult->Fetch()
  * 
  * @return array|false
  */
 public function fetch()
 {
     if (is_null($this->selectResult)) {
         $this->getResult();
     }
     return $this->selectResult->Fetch();
 }
Пример #17
0
 public static function Fetch()
 {
     global $DB;
     $res = parent::Fetch();
     if (!is_object($this)) {
         return $res;
     }
     if ($res) {
         if (isset($res["USER_ID"])) {
             $USER_ID = intval($res["USER_ID"]);
         } elseif (isset($res["LAST_USER_ID"])) {
             $USER_ID = intval($res["LAST_USER_ID"]);
         } else {
             $USER_ID = 0;
         }
         if ($USER_ID > 0 && !isset($res["LOGIN"])) {
             $rsUser = $DB->Query("\n\t\t\t\t\tSELECT LOGIN, " . $DB->Concat($DB->IsNull("NAME", "''"), "' '", $DB->IsNull("LAST_NAME", "''")) . " USER_NAME\n\t\t\t\t\tFROM b_user\n\t\t\t\t\tWHERE ID = " . $USER_ID . "\n\t\t\t\t");
             $arUser = $rsUser->Fetch();
             if (is_array($arUser)) {
                 $res["LOGIN"] = $arUser["LOGIN"];
                 $res["USER_NAME"] = $arUser["USER_NAME"];
             } else {
                 $res["LOGIN"] = "";
                 $res["USER_NAME"] = " ";
             }
         }
     }
     return $res;
 }
Пример #18
0
 /**
  * @param $by
  * @param $order
  * @param $arFilter
  *
  * @return CDBResult
  *
  * пока не знаю для чего эта функция, но может пригодиться
  */
 function GetList($by, $order, $arFilter)
 {
     global $DB;
     $query = $DB->Query('SELECT "NAME, CHANGED" FROM p_parser_res_list');
     while ($res = $query->Fetch()) {
         $elem['ID'] = $res['ID'];
         $elem['NAME'] = $res['NAME'];
         $elem['ACTIVE'] = $res['ACTIVE'];
         $elem['DATE_ACTIVE_FROM'] = $res['DATE_ACTIVE_FROM'];
         $elem['DATE_ACTIVE_TO'] = $res['DATE_ACTIVE_TO'];
         $arResult[] = $elem;
     }
     $result = new CDBResult();
     $result->InitFromArray($arResult);
     return $result;
 }
Пример #19
0
 function Fetch()
 {
     static $arSite = array();
     $r = parent::Fetch();
     if ($r) {
         $site_id = $r["SITE_ID"];
         if (!isset($arSite[$site_id])) {
             $rsSite = CSite::GetList($b, $o, array("ID" => $site_id));
             $arSite[$site_id] = $rsSite->Fetch();
         }
         $r["DIR"] = $arSite[$site_id]["DIR"];
         $r["SERVER_NAME"] = $arSite[$site_id]["SERVER_NAME"];
         if (strlen($r["SITE_URL"]) > 0) {
             $r["URL"] = $r["SITE_URL"];
         }
         if (substr($r["URL"], 0, 1) == "=") {
             foreach (GetModuleEvents("search", "OnSearchGetURL", true) as $arEvent) {
                 $r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
             }
         }
         $r["URL"] = str_replace(array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"), array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]), $r["URL"]);
         $r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);
         unset($r["SITE_URL"]);
     }
     return $r;
 }
Пример #20
0
 function elemGetEx($elemId = false)
 {
     $hlHandler = $this->hlHandler;
     $getList = new Entity\Query($hlHandler);
     $getList->setSelect(array('*'));
     $getList->setOrder(array("ID" => "ASC"));
     if (!empty($elemId)) {
         $getList->setFilter(array("ID" => $elemId));
     }
     $result = $getList->exec();
     $result = new CDBResult($result);
     $arRes = array();
     while ($row = $result->Fetch()) {
         $arRes[] = $row;
     }
     return $arRes;
 }
Пример #21
0
 function Fetch()
 {
     $a = parent::Fetch();
     if ($a && defined("BX_COMP_MANAGED_CACHE")) {
         $GLOBALS["CACHE_MANAGER"]->RegisterTag("iblock_property_enum_" . $a["PROPERTY_ID"]);
     }
     return $a;
 }
Пример #22
0
 function __construct(Entity $entity, \CDBResult $DBResult = null)
 {
     if ($entity instanceof Entity) {
         $this->_obxDBSimpleEntity = $entity;
     } else {
         throw new \ErrorException(__CLASS__ . ': entity object not set');
     }
     parent::CDBResult($DBResult);
 }
Пример #23
0
	function Fetch()
	{
		$r = parent::Fetch();
		if($r)
		{
			$r["ID"] = $r["CITY_ID"];
			$r["NAME"] = $r["CITY_NAME"];
		}

		return $r;
	}
Пример #24
0
	public function Fetch()
	{
		$r = parent::Fetch();

		if($r)
		{
			if(strlen($r["SITE_URL"])>0)
				$r["URL"] = $r["SITE_URL"];

			if(substr($r["URL"], 0, 1)=="=")
			{
				$events = GetModuleEvents("search", "OnSearchGetURL");
				while ($arEvent = $events->Fetch())
					$r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
			}

			$r["URL"] = str_replace(
				array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"),
				array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]),
				$r["URL"]
			);
			$r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);

			$r["NAME"] = htmlspecialcharsex($r["TITLE"]);

			$preg_template = "/(^|[^".$this->_arStemFunc["pcre_letters"]."])(".str_replace("/", "\\/", implode("|", array_map('preg_quote', array_keys($this->_arPhrase)))).")/i".BX_UTF_PCRE_MODIFIER;
			if(preg_match_all($preg_template, ToUpper($r["NAME"]), $arMatches, PREG_OFFSET_CAPTURE))
			{
				$c = count($arMatches[2]);
				if(defined("BX_UTF"))
				{
					for($j = $c-1; $j >= 0; $j--)
					{
						$prefix = mb_substr($r["NAME"], 0, $arMatches[2][$j][1], 'latin1');
						$instr  = mb_substr($r["NAME"], $arMatches[2][$j][1], mb_strlen($arMatches[2][$j][0], 'latin1'), 'latin1');
						$suffix = mb_substr($r["NAME"], $arMatches[2][$j][1] + mb_strlen($arMatches[2][$j][0], 'latin1'), mb_strlen($r["NAME"], 'latin1'), 'latin1');
						$r["NAME"] = $prefix."<b>".$instr."</b>".$suffix;
					}
				}
				else
				{
					for($j = $c-1; $j >= 0; $j--)
					{
						$prefix = substr($r["NAME"], 0, $arMatches[2][$j][1]);
						$instr  = substr($r["NAME"], $arMatches[2][$j][1], strlen($arMatches[2][$j][0]));
						$suffix = substr($r["NAME"], $arMatches[2][$j][1]+strlen($arMatches[2][$j][0]));
						$r["NAME"] = $prefix."<b>".$instr."</b>".$suffix;
					}
				}
			}
		}

		return $r;
	}
Пример #25
0
 /** @return Int */
 public function getSelectedRowsCount()
 {
     if ($this->resource) {
         return $this->resource->getSelectedRowsCount();
     } elseif ($this->resourceCDBResult) {
         if (!$this->resourceCDBResult instanceof \CDBResultMysql) {
             $this->resourceCDBResult->NavStart(0);
         }
         return $this->resourceCDBResult->SelectedRowsCount();
     }
     return 0;
 }
Пример #26
0
 public static function GetByID($ID, $bFull = false)
 {
     global $DB;
     if ($res = self::_GetWhere($ID)) {
         $res = $DB->Query('SELECT * FROM b_intranet_sharepoint WHERE ' . $res);
         if ($bFull) {
             if ($arRes = $res->Fetch()) {
                 $res = $DB->Query('SELECT * FROM b_intranet_sharepoint_field WHERE IBLOCK_ID=\'' . $arRes['IBLOCK_ID'] . '\'');
                 $arRes['FIELDS'] = array();
                 while ($arField = $res->Fetch()) {
                     $arRes['FIELDS'][] = $arField;
                 }
                 $res = new CDBResult();
                 $res->InitFromArray(array($arRes));
             }
         }
     } else {
         $res = new CDBResult();
     }
     return $res;
 }
Пример #27
0
 public function fetch($filter, $params = array())
 {
     // ����������� ������
     ksort($filter);
     foreach ($filter as &$f) {
         if (is_array($f)) {
             sort($f);
         }
     }
     // ��������� � id ���� ��� ��������� ���������
     $cacheId = serialize($filter);
     if (isset($params['count'])) {
         $cacheId .= '+cnt' . $params['count'];
     }
     if (isset($params['pageSize'])) {
         $cacheId .= '+ps' . $params['pageSize'] . '-' . CDBResult::navStringForCache($params['pageSize']);
     }
     if (isset($params['sort'])) {
         $cacheId .= '+s' . serialize($params['sort']);
     } else {
         $params['sort'] = array('id' => 'desc');
     }
     // ��������� ���
     $cache = new CPhpCache();
     if (false && $cache->initCache($this->_cacheTime, $cacheId, $this->_cacheDir)) {
         $vars = $cache->getVars();
         // ��� ����, ����� ������������ ����������� ���������, ��������� CDBResult
         $this->_dbResult = new CDBResult();
         if (isset($params['pageSize'])) {
             $this->_dbResult->InitFromArray((int) $vars['total'] > 0 ? array_fill(0, $vars['total'], 0) : array());
             if (isset($params['pageSize'])) {
                 $this->_dbResult->navStart($params['pageSize'], true, $vars['page']);
             }
         }
         return $vars['items'];
     }
     // � ���� ���
     CMOdule::includeModule('iblock');
     $filter['IBLOCK_ID'] = isset($filter['IBLOCK_ID']) ? $filter['IBLOCK_ID'] : $this->_iblockId;
     $filter['ACTIVE'] = 'Y';
     $this->_dbResult = CIBlockElement::getList($params['sort'], $filter, false, isset($params['count']) ? array('nTopCount' => $params['count']) : false, $this->_commonSelect);
     if (isset($params['pageSize'])) {
         $this->_dbResult->navStart($params['pageSize']);
     }
     $result = array();
     while ($row = $this->_dbResult->fetch()) {
         $result[$row['ID']] = $row;
     }
     if ($cache->startDataCache()) {
         $cache->endDataCache(array('items' => $result, 'total' => $this->_dbResult->NavRecordCount, 'page' => $this->_dbResult->NavPageNomer));
     }
     return $result;
 }
Пример #28
0
 public static function Fetch()
 {
     global $DB;
     $ar = parent::Fetch();
     if ($ar) {
         if (isset($ar["Tables_in_" . $DB->DBName])) {
             $ar = array("TABLE_NAME" => $ar["Tables_in_" . $DB->DBName], "ENGINE_TYPE" => "", "NUM_ROWS" => "", "BYTES" => "");
         } else {
             $ar = array("TABLE_NAME" => $ar["Name"], "ENGINE_TYPE" => $ar["Comment"] === "VIEW" ? "VIEW" : $ar["Engine"], "NUM_ROWS" => $ar["Rows"], "BYTES" => $ar["Data_length"]);
         }
     }
     return $ar;
 }
Пример #29
0
 public static function GetList($arFilter = array(), $arGroupBy = false, $arSelectFields = array())
 {
     $params = array();
     if (is_array($arFilter) && !empty($arFilter)) {
         if (isset($arFilter["DELIVERY_ID"]) || $arFilter["DELIVERY_PROFILE_ID"]) {
             $ids = self::convertDeliveryIds(isset($arFilter["DELIVERY_ID"]) ? $arFilter["DELIVERY_ID"] : array(), isset($arFilter["DELIVERY_PROFILE_ID"]) ? $arFilter["DELIVERY_PROFILE_ID"] : array());
             if (!empty($ids)) {
                 $arFilter["=DELIVERY_ID"] = $ids;
             }
             unset($arFilter["DELIVERY_ID"]);
             unset($arFilter["DELIVERY_PROFILE_ID"]);
         }
         if (isset($arFilter["PAYSYSTEM_ID"])) {
             $arFilter["=PAYSYSTEM_ID"] = $arFilter["PAYSYSTEM_ID"];
             unset($arFilter["PAYSYSTEM_ID"]);
         }
         $params['filter'] = $arFilter;
     }
     //todo:
     if (is_array($arGroupBy) && !empty($arGroupBy)) {
         $params['group'] = array_intersect($arGroupBy, array("DELIVERY_ID", "PAYSYSTEM_ID"));
     }
     $params["select"] = array("DELIVERY_ID", "PAYSYSTEM_ID", "DELIVERY_SERVICE_CODE" => "DELIVERY_SERVICE.CODE");
     $params["runtime"] = array(new \Bitrix\Main\Entity\ReferenceField('DELIVERY_SERVICE', 'Bitrix\\Sale\\Delivery\\Services\\Table', array('=this.DELIVERY_ID' => 'ref.ID')));
     $records = array();
     $res = DeliveryPaySystemTable::getList($params);
     while ($record = $res->fetch()) {
         $delivery = CSaleDeliveryHelper::getDeliverySIDAndProfile($record["DELIVERY_SERVICE_CODE"]);
         $record["DELIVERY_ID"] = $delivery["SID"];
         $record["DELIVERY_PROFILE_ID"] = isset($delivery["PROFILE"]) ? $delivery["PROFILE"] : null;
         unset($record["DELIVERY_SERVICE_CODE"]);
         $records[] = $record;
     }
     $result = new \CDBResult();
     $result->InitFromArray($records);
     return $result;
 }
Пример #30
0
 protected function setNavStartParams()
 {
     if ($this->arParams['PAGER_SAVE_SESSION'] !== 'Y') {
         \CPageOption::SetOptionString('main', 'nav_page_in_session', 'N');
     }
     $this->arParams['PAGER_DESC_NUMBERING'] = $this->arParams['PAGER_DESC_NUMBERING'] === 'Y';
     if ($this->arParams['DISPLAY_BOTTOM_PAGER'] === 'Y' || $this->arParams['DISPLAY_TOP_PAGER'] === 'Y') {
         $this->navStartParams = ['nPageSize' => $this->arParams['ELEMENTS_COUNT'], 'bDescPageNumbering' => $this->arParams['PAGER_DESC_NUMBERING'], 'bShowAll' => $this->arParams['PAGER_SHOW_ALL']];
         $this->addCacheAdditionalId(\CDBResult::GetNavParams($this->navStartParams));
     } elseif ($this->arParams['ELEMENTS_COUNT'] > 0) {
         $this->navStartParams = ['nTopCount' => $this->arParams['ELEMENTS_COUNT'], 'bDescPageNumbering' => $this->arParams['PAGER_DESC_NUMBERING']];
     } else {
         $this->navStartParams = false;
     }
 }