当前位置: 首页>>代码示例>>PHP>>正文


PHP CCatalog::PrepareSql方法代码示例

本文整理汇总了PHP中CCatalog::PrepareSql方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalog::PrepareSql方法的具体用法?PHP CCatalog::PrepareSql怎么用?PHP CCatalog::PrepareSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCatalog的用法示例。


在下文中一共展示了CCatalog::PrepareSql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:58,代码来源:product_group.php

示例2: 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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:58,代码来源:store_docs_element.php

示例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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:58,代码来源:store_product.php

示例4: GetList

 function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     // for old execution style
     if (!is_array($arOrder) && !is_array($arFilter)) {
         $arOrder = strval($arOrder);
         $arFilter = strval($arFilter);
         if ('' != $arOrder && '' != $arFilter) {
             $arOrder = array($arOrder => $arFilter);
         } else {
             $arOrder = array();
         }
         $arFilter = array();
         $arGroupBy = false;
     }
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "NAME", "PERCENTAGE");
     }
     $arFields = array("ID" => array("FIELD" => "E.ID", "TYPE" => "int"), "NAME" => array("FIELD" => "E.NAME", "TYPE" => "string"), "PERCENTAGE" => array("FIELD" => "E.PERCENTAGE", "TYPE" => "double"));
     $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_extra E " . $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_extra E " . $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"];
     }
     $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_extra E " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " LIMIT " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:78,代码来源:extra.php

示例5: getList

 static function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "DOC_TYPE", "SITE_ID", "CONTRACTOR_ID", "CURRENCY", "STATUS", "DATE_DOCUMENT", "TOTAL", "DATE_STATUS", "COMMENTARY");
     }
     $arFields = array("ID" => array("FIELD" => "CD.ID", "TYPE" => "int"), "DOC_TYPE" => array("FIELD" => "CD.DOC_TYPE", "TYPE" => "char"), "SITE_ID" => array("FIELD" => "CD.SITE_ID", "TYPE" => "string"), "CURRENCY" => array("FIELD" => "CD.CURRENCY", "TYPE" => "string"), "CONTRACTOR_ID" => array("FIELD" => "CD.CONTRACTOR_ID", "TYPE" => "int"), "DATE_CREATE" => array("FIELD" => "CD.DATE_CREATE", "TYPE" => "datetime"), "DATE_MODIFY" => array("FIELD" => "CD.DATE_MODIFY", "TYPE" => "datetime"), "DATE_DOCUMENT" => array("FIELD" => "CD.DATE_DOCUMENT", "TYPE" => "datetime"), "DATE_STATUS" => array("FIELD" => "CD.DATE_STATUS", "TYPE" => "datetime"), "CREATED_BY" => array("FIELD" => "CD.CREATED_BY", "TYPE" => "int"), "MODIFIED_BY" => array("FIELD" => "CD.MODIFIED_BY", "TYPE" => "int"), "STATUS_BY" => array("FIELD" => "CD.STATUS_BY", "TYPE" => "int"), "STATUS" => array("FIELD" => "CD.STATUS", "TYPE" => "string"), "TOTAL" => array("FIELD" => "CD.TOTAL", "TYPE" => "double"), "COMMENTARY" => array("FIELD" => "CD.COMMENTARY", "TYPE" => "string"), "PRODUCTS_ID" => array("FIELD" => "DE.ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_ID)"), "PRODUCTS_DOC_ID" => array("FIELD" => "DE.DOC_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_ID)"), "PRODUCTS_STORE_FROM" => array("FIELD" => "DE.STORE_FROM", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_ID)"), "PRODUCTS_STORE_TO" => array("FIELD" => "DE.STORE_TO", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_ID)"), "PRODUCTS_ELEMENT_ID" => array("FIELD" => "DE.ELEMENT_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_ID)"), "PRODUCTS_AMOUNT" => array("FIELD" => "DE.AMOUNT", "TYPE" => "double", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_ID)"), "PRODUCTS_PURCHASING_PRICE" => array("FIELD" => "DE.PURCHASING_PRICE", "TYPE" => "double", "FROM" => "INNER JOIN b_catalog_docs_element DE ON (CD.ID = DE.DOC_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_store_docs CD " . $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_store_docs CD " . $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"];
     }
     $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_store_docs CD " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " LIMIT " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:66,代码来源:store_docs.php

示例6: __GetDiscountID

 protected function __GetDiscountID($arFilter)
 {
     global $DB;
     $arResult = array();
     $boolRest = array_key_exists('RESTRICTIONS', $arFilter);
     $arFields = array("DISCOUNT_ID" => array("FIELD" => "DC.DISCOUNT_ID", "TYPE" => "int"), "ACTIVE" => array("FIELD" => "DC.ACTIVE", "TYPE" => "char"), "USER_GROUP_ID" => array("FIELD" => "DC.USER_GROUP_ID", "TYPE" => "int"), "PRICE_TYPE_ID" => array("FIELD" => "DC.PRICE_TYPE_ID", "TYPE" => "int"));
     if (!isset($arFilter['USER_GROUP_ID'])) {
         $arFilter['USER_GROUP_ID'] = array();
     } elseif (!is_array($arFilter['USER_GROUP_ID'])) {
         $arFilter['USER_GROUP_ID'] = array($arFilter['USER_GROUP_ID']);
     }
     if (!empty($arFilter['USER_GROUP_ID'])) {
         $arFilter['USER_GROUP_ID'][] = -1;
     } else {
         unset($arFilter['USER_GROUP_ID']);
     }
     if (!isset($arFilter['PRICE_TYPE_ID'])) {
         $arFilter['PRICE_TYPE_ID'] = array();
     } elseif (!is_array($arFilter['PRICE_TYPE_ID'])) {
         $arFilter['PRICE_TYPE_ID'] = array($arFilter['PRICE_TYPE_ID']);
     }
     if (!empty($arFilter['PRICE_TYPE_ID'])) {
         $arFilter['PRICE_TYPE_ID'][] = -1;
     } else {
         unset($arFilter['PRICE_TYPE_ID']);
     }
     $active = 'Y';
     if (array_key_exists('ACTIVE', $arFilter)) {
         if ($arFilter['ACTIVE'] === null) {
             $active = '';
         } elseif ($arFilter['ACTIVE'] == 'Y' || $arFilter['ACTIVE'] == 'N') {
             $active = $arFilter['ACTIVE'];
         }
         unset($arFilter['ACTIVE']);
     }
     if ($active != '') {
         $arFilter['ACTIVE'] = $active;
     }
     if (array_key_exists('DISCOUNT_ID', $arFilter)) {
         unset($arFilter['DISCOUNT_ID']);
     }
     $arSelectFields = array('DISCOUNT_ID');
     if ($boolRest) {
         $arSelectFields[] = 'USER_GROUP_ID';
         $arSelectFields[] = 'PRICE_TYPE_ID';
         unset($arFilter['RESTRICTIONS']);
     }
     $arSqls = CCatalog::PrepareSql($arFields, array(), $arFilter, false, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (empty($arSqls["WHERE"])) {
         $arSqls["WHERE"] = "1=1";
     }
     $strQuery = "SELECT " . $arSqls["SELECT"] . " FROM b_catalog_discount_cond DC WHERE " . $arSqls["WHERE"];
     $arDiscountID = array();
     $rsDiscounts = $DB->Query($strQuery, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($boolRest) {
         $arRestrictions = array();
         while ($arDiscount = $rsDiscounts->Fetch()) {
             $arDiscount['DISCOUNT_ID'] = intval($arDiscount['DISCOUNT_ID']);
             $arDiscountID[$arDiscount['DISCOUNT_ID']] = true;
             if (!array_key_exists($arDiscount['DISCOUNT_ID'], $arRestrictions)) {
                 $arRestrictions[$arDiscount['DISCOUNT_ID']] = array('USER_GROUP' => array(), 'PRICE_TYPE' => array());
             }
             $arDiscount['USER_GROUP_ID'] = intval($arDiscount['USER_GROUP_ID']);
             $arDiscount['PRICE_TYPE_ID'] = intval($arDiscount['PRICE_TYPE_ID']);
             $arRestrictions[$arDiscount['DISCOUNT_ID']]['USER_GROUP'][$arDiscount['USER_GROUP_ID']] = true;
             $arRestrictions[$arDiscount['DISCOUNT_ID']]['PRICE_TYPE'][$arDiscount['PRICE_TYPE_ID']] = true;
         }
         if (!empty($arDiscountID)) {
             $arDiscountID = array_keys($arDiscountID);
             foreach ($arRestrictions as $intKey => $arOneRestrictions) {
                 if (array_key_exists(-1, $arOneRestrictions['USER_GROUP'])) {
                     $arOneRestrictions['USER_GROUP'] = array();
                 }
                 if (array_key_exists(-1, $arOneRestrictions['PRICE_TYPE'])) {
                     $arOneRestrictions['PRICE_TYPE'] = array();
                 }
                 $arRestrictions[$intKey] = $arOneRestrictions;
             }
         }
         $arResult = array('DISCOUNTS' => $arDiscountID, 'RESTRICTIONS' => $arRestrictions);
     } else {
         while ($arDiscount = $rsDiscounts->Fetch()) {
             $arDiscount['DISCOUNT_ID'] = intval($arDiscount['DISCOUNT_ID']);
             $arDiscountID[$arDiscount['DISCOUNT_ID']] = true;
         }
         if (!empty($arDiscountID)) {
             $arResult = array_keys($arDiscountID);
         }
     }
     return $arResult;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:92,代码来源:discount.php

示例7: GetList


//.........这里部分代码省略.........
  *
  *
  *
  * @return CDBResult <p>Метод возвращает объект класса CDBResult.</p>
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * if (CModule::IncludeModule("catalog"))
  * { 
  *    $arFilter = array('COUPON' =&gt; 'CP-R8RFW-5YGGPZJ'); 
  *    $dbCoupon = CCatalogDiscountCoupon::GetList (array(), $arFilter); 
  *    if($arCoupon = $dbCoupon-&gt;Fetch()) 
  *    { 
  *        echo "&lt;pre&gt;"; 
  *        print_r($arCoupon); 
  *        echo "&lt;/pre&gt;"; 
  *    } 
  *    else
  *    { 
  *        echo "купона нет"; 
  *    } 
  * }
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li><a href="http://dev.1c-bitrix.ru/api_help/catalog/fields.php">Структура таблицы</a></li> <li><a
  * href="http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogdiscountcoupon/getbyid.php">CCatalogDiscountCoupon::GetByID</a></li>
  * </ul> </ht
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogdiscountcoupon/getlist.php
  * @author Bitrix
  */
 public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     $arFields = array("ID" => array("FIELD" => "CD.ID", "TYPE" => "int"), "DISCOUNT_ID" => array("FIELD" => "CD.DISCOUNT_ID", "TYPE" => "string"), "ACTIVE" => array("FIELD" => "CD.ACTIVE", "TYPE" => "char"), "ONE_TIME" => array("FIELD" => "CD.ONE_TIME", "TYPE" => "char"), "COUPON" => array("FIELD" => "CD.COUPON", "TYPE" => "string"), "DATE_APPLY" => array("FIELD" => "CD.DATE_APPLY", "TYPE" => "datetime"), "DISCOUNT_NAME" => array("FIELD" => "CDD.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_catalog_discount CDD ON (CD.DISCOUNT_ID = CDD.ID)"), "DESCRIPTION" => array("FIELD" => "CD.DESCRIPTION", "TYPE" => "string"), "TIMESTAMP_X" => array("FIELD" => "CD.TIMESTAMP_X", "TYPE" => "datetime"), "MODIFIED_BY" => array("FIELD" => "CD.MODIFIED_BY", "TYPE" => "int"), "DATE_CREATE" => array("FIELD" => "CD.DATE_CREATE", "TYPE" => "datetime"), "CREATED_BY" => array("FIELD" => "CD.CREATED_BY", "TYPE" => "int"));
     $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_discount_coupon CD " . $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_discount_coupon CD " . $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"];
     }
     $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_discount_coupon CD " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " LIMIT " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:discount_coupon.php

示例8: getList

 static function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "DOC_ELEMENT_ID", "BARCODE");
     }
     $arFields = array("ID" => array("FIELD" => "DB.ID", "TYPE" => "int"), "DOC_ELEMENT_ID" => array("FIELD" => "DB.DOC_ELEMENT_ID", "TYPE" => "int"), "BARCODE" => array("FIELD" => "DB.BARCODE", "TYPE" => "string"));
     $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_docs_barcode DB " . $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_docs_barcode DB " . $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"];
     }
     $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_docs_barcode DB " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " LIMIT " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:66,代码来源:store_docs_barcode.php

示例9: getList

 static function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "CODE", "MEASURE_TITLE", "SYMBOL_RUS", "SYMBOL_INTL", "SYMBOL_LETTER_INTL", "IS_DEFAULT");
     } elseif (is_array($arSelectFields)) {
         if (!in_array('*', $arSelectFields)) {
             $selectCodes = array_fill_keys($arSelectFields, true);
             if (!isset($selectCodes['CODE'])) {
                 $arSelectFields[] = 'CODE';
             }
             if ((isset($selectCodes['MEASURE_TITLE']) || isset($selectCodes['SYMBOL_RUS'])) && !isset($selectCodes['SYMBOL_INTL'])) {
                 $arSelectFields[] = 'SYMBOL_INTL';
             }
             unset($selectCodes);
         }
     }
     $arFields = array("ID" => array("FIELD" => "CM.ID", "TYPE" => "int"), "CODE" => array("FIELD" => "CM.CODE", "TYPE" => "int"), "MEASURE_TITLE" => array("FIELD" => "CM.MEASURE_TITLE", "TYPE" => "string"), "SYMBOL_RUS" => array("FIELD" => "CM.SYMBOL_RUS", "TYPE" => "string"), "SYMBOL_INTL" => array("FIELD" => "CM.SYMBOL_INTL", "TYPE" => "string"), "SYMBOL_LETTER_INTL" => array("FIELD" => "CM.SYMBOL_LETTER_INTL", "TYPE" => "string"), "IS_DEFAULT" => array("FIELD" => "CM.IS_DEFAULT", "TYPE" => "char"));
     $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_measure CM " . $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_measure CM " . $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"];
     }
     $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_measure CM " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " LIMIT " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     $dbMeasure = new CCatalogMeasureResult($dbRes);
     return $dbMeasure;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:78,代码来源:measure.php

示例10: GetList

 static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "ACTIVE", "TITLE", "PHONE", "SCHEDULE", "ADDRESS", "DESCRIPTION", "GPS_N", "GPS_S", "IMAGE_ID", "DATE_CREATE", "DATE_MODIFY", "USER_ID", "XML_ID", "SORT", "EMAIL", "ISSUING_CENTER", "SHIPPING_CENTER", "SITE_ID");
     }
     $keyForDelete = array_search("PRODUCT_AMOUNT", $arSelectFields);
     if (!isset($arFilter["PRODUCT_ID"]) && $keyForDelete !== false) {
         unset($arSelectFields[$keyForDelete]);
     }
     if ($keyForDelete == false) {
         $keyForDelete = array_search("ELEMENT_ID", $arSelectFields);
         if ($keyForDelete !== false) {
             unset($arSelectFields[$keyForDelete]);
         }
     }
     $productID = '(';
     if (is_array($arFilter["PRODUCT_ID"])) {
         foreach ($arFilter["PRODUCT_ID"] as $id) {
             $productID .= intval($id) . ',';
         }
         $productID = rtrim($productID, ',') . ')';
     } else {
         $productID .= intval($arFilter["PRODUCT_ID"]) . ')';
     }
     $arFields = array("ID" => array("FIELD" => "CS.ID", "TYPE" => "int"), "ACTIVE" => array("FIELD" => "CS.ACTIVE", "TYPE" => "string"), "TITLE" => array("FIELD" => "CS.TITLE", "TYPE" => "string"), "PHONE" => array("FIELD" => "CS.PHONE", "TYPE" => "string"), "SCHEDULE" => array("FIELD" => "CS.SCHEDULE", "TYPE" => "string"), "ADDRESS" => array("FIELD" => "CS.ADDRESS", "TYPE" => "string"), "DESCRIPTION" => array("FIELD" => "CS.DESCRIPTION", "TYPE" => "string"), "GPS_N" => array("FIELD" => "CS.GPS_N", "TYPE" => "string"), "GPS_S" => array("FIELD" => "CS.GPS_S", "TYPE" => "string"), "IMAGE_ID" => array("FIELD" => "CS.IMAGE_ID", "TYPE" => "int"), "LOCATION_ID" => array("FIELD" => "CS.LOCATION_ID", "TYPE" => "int"), "DATE_CREATE" => array("FIELD" => "CS.DATE_CREATE", "TYPE" => "datetime"), "DATE_MODIFY" => array("FIELD" => "CS.DATE_MODIFY", "TYPE" => "datetime"), "USER_ID" => array("FIELD" => "CS.USER_ID", "TYPE" => "int"), "MODIFIED_BY" => array("FIELD" => "CS.MODIFIED_BY", "TYPE" => "int"), "XML_ID" => array("FIELD" => "CS.XML_ID", "TYPE" => "string"), "SORT" => array("FIELD" => "CS.SORT", "TYPE" => "int"), "EMAIL" => array("FIELD" => "CS.EMAIL", "TYPE" => "string"), "ISSUING_CENTER" => array("FIELD" => "CS.ISSUING_CENTER", "TYPE" => "char"), "SHIPPING_CENTER" => array("FIELD" => "CS.SHIPPING_CENTER", "TYPE" => "char"), "SITE_ID" => array("FIELD" => "CS.SITE_ID", "TYPE" => "string"), "PRODUCT_AMOUNT" => array("FIELD" => "CP.AMOUNT", "TYPE" => "double", "FROM" => "LEFT JOIN b_catalog_store_product CP ON (CS.ID = CP.STORE_ID AND CP.PRODUCT_ID IN " . $productID . ")"), "ELEMENT_ID" => array("FIELD" => "CP.PRODUCT_ID", "TYPE" => "int"));
     $userField = new CUserTypeSQL();
     $userField->SetEntity("CAT_STORE", "CS.ID");
     $userField->SetSelect($arSelectFields);
     $userField->SetFilter($arFilter);
     $userField->SetOrder($arOrder);
     $strUfFilter = $userField->GetFilter();
     $strSqlUfFilter = strlen($strUfFilter) > 0 ? " (" . $strUfFilter . ") " : "";
     $strSqlUfOrder = "";
     foreach ($arOrder as $field => $by) {
         $field = $userField->GetOrder($field);
         if (empty($field)) {
             continue;
         }
         if (strlen($strSqlUfOrder) > 0) {
             $strSqlUfOrder .= ', ';
         }
         $strSqlUfOrder .= $field . " " . $by;
     }
     $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"] . " " . $userField->GetSelect() . " FROM b_catalog_store CS " . $arSqls["FROM"] . " " . $userField->GetJoin("CS.ID");
         if (!empty($arSqls["WHERE"])) {
             $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 (!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"] . " " . $userField->GetSelect() . " FROM b_catalog_store CS " . $arSqls["FROM"] . " " . $userField->GetJoin("CS.ID");
     if (!empty($arSqls["WHERE"])) {
         $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 (!empty($arSqls["GROUPBY"])) {
         $strSql .= " GROUP BY " . $arSqls["GROUPBY"];
     }
     if (!empty($arSqls["ORDERBY"])) {
         $strSql .= " ORDER BY " . $arSqls["ORDERBY"];
     } elseif (strlen($arSqls["ORDERBY"]) <= 0 && strlen($strSqlUfOrder) > 0) {
         $strSql .= " ORDER BY " . $strSqlUfOrder;
     }
     $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_store CS " . $arSqls["FROM"] . " " . $userField->GetJoin("CS.ID");
         if (!empty($arSqls["WHERE"])) {
             $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 (!empty($arSqls["GROUPBY"])) {
             $strSql_tmp .= " GROUP BY " . $arSqls["GROUPBY"];
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:store.php

示例11: GetList

 function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     // For old-style execution
     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" => "I.ID", "TYPE" => "int"), "IBLOCK_ID" => array("FIELD" => "CI.IBLOCK_ID", "TYPE" => "int"), "YANDEX_EXPORT" => array("FIELD" => "CI.YANDEX_EXPORT", "TYPE" => "char"), "SUBSCRIPTION" => array("FIELD" => "CI.SUBSCRIPTION", "TYPE" => "char"), "PRODUCT_IBLOCK_ID" => array("FIELD" => "CI.PRODUCT_IBLOCK_ID", "TYPE" => "int"), "SKU_PROPERTY_ID" => array("FIELD" => "CI.SKU_PROPERTY_ID", "TYPE" => "int"), "OFFERS_PROPERTY_ID" => array("FIELD" => "OFFERS.SKU_PROPERTY_ID", "TYPE" => "int"), "OFFERS_IBLOCK_ID" => array("FIELD" => "OFFERS.IBLOCK_ID", "TYPE" => "int"), "IBLOCK_TYPE_ID" => array("FIELD" => "I.IBLOCK_TYPE_ID", "TYPE" => "string"), "IBLOCK_ACTIVE" => array("FIELD" => "I.ACTIVE", "TYPE" => "char"), "LID" => array("FIELD" => "I.LID", "TYPE" => "string"), "NAME" => array("FIELD" => "I.NAME", "TYPE" => "string"));
     // <-- FIELDS
     $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_iblock CI\n\t\t\t\tINNER JOIN b_iblock I ON CI.IBLOCK_ID = I.ID\n\t\t\t\tLEFT JOIN b_catalog_iblock OFFERS ON CI.IBLOCK_ID = OFFERS.PRODUCT_IBLOCK_ID" . " " . $arSqls["FROM"] . " " . "WHERE 1=1 ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql .= "AND " . $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_iblock CI\n\t\t\tINNER JOIN b_iblock I ON CI.IBLOCK_ID = I.ID\n\t\t\tLEFT JOIN b_catalog_iblock OFFERS ON CI.IBLOCK_ID = OFFERS.PRODUCT_IBLOCK_ID" . " " . $arSqls["FROM"] . " " . "WHERE 1=1 ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "AND " . $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_iblock CI\n\t\t\t\tINNER JOIN b_iblock I ON CI.IBLOCK_ID = I.ID\n\t\t\t\tLEFT JOIN b_catalog_iblock OFFERS ON CI.IBLOCK_ID = OFFERS.PRODUCT_IBLOCK_ID" . " " . $arSqls["FROM"] . " " . "WHERE 1=1 ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "AND " . $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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:76,代码来源:catalog.php

示例12: getList

 static function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (count($arSelectFields) <= 0) {
         $arSelectFields = array("ID", "PRODUCT_ID", "STORE_ID", "BARCODE", "ORDER_ID");
     }
     $arFields = array("ID" => array("FIELD" => "CB.ID", "TYPE" => "int"), "PRODUCT_ID" => array("FIELD" => "CB.PRODUCT_ID", "TYPE" => "int"), "STORE_ID" => array("FIELD" => "CB.STORE_ID", "TYPE" => "int"), "BARCODE" => array("FIELD" => "CB.BARCODE", "TYPE" => "string"), "ORDER_ID" => array("FIELD" => "CB.ORDER_ID", "TYPE" => "int"));
     $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_barcode CB " . "\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_barcode CB " . "\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_barcode CB " . "\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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:61,代码来源:store_barcode.php

示例13: GetListEx

 /**
  * @param array $arOrder
  * @param array $arFilter
  * @param bool|array $arGroupBy
  * @param bool|array $arNavStartParams
  * @param array $arSelectFields
  * @return bool|CDBResult
  */
 function GetListEx($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "PRODUCT_ID", "EXTRA_ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "TIMESTAMP_X", "QUANTITY_FROM", "QUANTITY_TO", "TMP_ID");
     }
     $arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "PRODUCT_ID" => array("FIELD" => "P.PRODUCT_ID", "TYPE" => "int"), "EXTRA_ID" => array("FIELD" => "P.EXTRA_ID", "TYPE" => "int"), "CATALOG_GROUP_ID" => array("FIELD" => "P.CATALOG_GROUP_ID", "TYPE" => "int"), "PRICE" => array("FIELD" => "P.PRICE", "TYPE" => "double"), "CURRENCY" => array("FIELD" => "P.CURRENCY", "TYPE" => "string"), "TIMESTAMP_X" => array("FIELD" => "P.TIMESTAMP_X", "TYPE" => "datetime"), "QUANTITY_FROM" => array("FIELD" => "P.QUANTITY_FROM", "TYPE" => "int"), "QUANTITY_TO" => array("FIELD" => "P.QUANTITY_TO", "TYPE" => "int"), "TMP_ID" => array("FIELD" => "P.TMP_ID", "TYPE" => "string"), "PRICE_BASE_RATE" => array("FIELD" => "P.PRICE*CC.CURRENT_BASE_RATE", "TYPE" => "double", "FROM" => "LEFT JOIN b_catalog_currency CC ON (P.CURRENCY = CC.CURRENCY)"), "PRODUCT_QUANTITY" => array("FIELD" => "CP.QUANTITY", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_product CP ON (P.PRODUCT_ID = CP.ID)"), "PRODUCT_QUANTITY_TRACE" => array("FIELD" => "IF (CP.QUANTITY_TRACE = 'D', '" . $DB->ForSql((string) Option::get('catalog', 'default_quantity_trace', 'N')) . "', CP.QUANTITY_TRACE)", "TYPE" => "char", "FROM" => "INNER JOIN b_catalog_product CP ON (P.PRODUCT_ID = CP.ID)"), "PRODUCT_CAN_BUY_ZERO" => array("FIELD" => "IF (CP.CAN_BUY_ZERO = 'D', '" . $DB->ForSql((string) Option::get('catalog', 'default_can_buy_zero', 'N')) . "', CP.CAN_BUY_ZERO)", "TYPE" => "char", "FROM" => "INNER JOIN b_catalog_product CP ON (P.PRODUCT_ID = CP.ID)"), "PRODUCT_NEGATIVE_AMOUNT_TRACE" => array("FIELD" => "IF (CP.NEGATIVE_AMOUNT_TRACE = 'D', '" . $DB->ForSql((string) Option::get('catalog', 'allow_negative_amount', 'N')) . "', CP.NEGATIVE_AMOUNT_TRACE)", "TYPE" => "char", "FROM" => "INNER JOIN b_catalog_product CP ON (P.PRODUCT_ID = CP.ID)"), "PRODUCT_WEIGHT" => array("FIELD" => "CP.WEIGHT", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_product CP ON (P.PRODUCT_ID = CP.ID)"), "ELEMENT_IBLOCK_ID" => array("FIELD" => "IE.IBLOCK_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_iblock_element IE ON (P.PRODUCT_ID = IE.ID)"), "ELEMENT_NAME" => array("FIELD" => "IE.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_iblock_element IE ON (P.PRODUCT_ID = IE.ID)"), "CATALOG_GROUP_CODE" => array("FIELD" => "CG.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_catalog_group CG ON (P.CATALOG_GROUP_ID = CG.ID)"), "CATALOG_GROUP_BASE" => array("FIELD" => "CG.BASE", "TYPE" => "char", "FROM" => "INNER JOIN b_catalog_group CG ON (P.CATALOG_GROUP_ID = CG.ID)"), "CATALOG_GROUP_SORT" => array("FIELD" => "CG.SORT", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_group CG ON (P.CATALOG_GROUP_ID = CG.ID)"), "CATALOG_GROUP_NAME" => array("FIELD" => "CGL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_catalog_group_lang CGL ON (P.CATALOG_GROUP_ID = CGL.CATALOG_GROUP_ID AND CGL.LANG = '" . LANGUAGE_ID . "')"), "GROUP_GROUP_ID" => array("FIELD" => "CGG.GROUP_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_catalog_group2group CGG ON (P.CATALOG_GROUP_ID = CGG.CATALOG_GROUP_ID)"), "GROUP_BUY" => array("FIELD" => "CGG.BUY", "TYPE" => "char", "FROM" => "INNER JOIN b_catalog_group2group CGG ON (P.CATALOG_GROUP_ID = CGG.CATALOG_GROUP_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_price P " . $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_price P " . $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"];
     }
     $intTopCount = 0;
     $boolNavStartParams = !empty($arNavStartParams) && is_array($arNavStartParams);
     if ($boolNavStartParams && isset($arNavStartParams['nTopCount'])) {
         $intTopCount = (int) $arNavStartParams["nTopCount"];
     }
     if ($boolNavStartParams && $intTopCount <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT FROM b_catalog_price P " . $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 ($boolNavStartParams && $intTopCount > 0) {
             $strSql .= " LIMIT " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:74,代码来源:price.php

示例14: getList

 public static function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (empty($arSelectFields)) {
         $arSelectFields = array("ID", "PRODUCT_ID", "RATIO");
     }
     $arFields = array("ID" => array("FIELD" => "MR.ID", "TYPE" => "int"), "PRODUCT_ID" => array("FIELD" => "MR.PRODUCT_ID", "TYPE" => "int"), "RATIO" => array("FIELD" => "MR.RATIO", "TYPE" => "double"));
     $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_measure_ratio MR " . $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_measure_ratio MR " . $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"];
     }
     $intTopCount = 0;
     $boolNavStartParams = !empty($arNavStartParams) && is_array($arNavStartParams);
     if ($boolNavStartParams && isset($arNavStartParams['nTopCount'])) {
         $intTopCount = intval($arNavStartParams["nTopCount"]);
     }
     if ($boolNavStartParams && 0 >= $intTopCount) {
         $strSql_tmp = "select COUNT('x') as CNT FROM b_catalog_measure_ratio MR " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " limit " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:66,代码来源:measure_ratio.php

示例15: getList

 public function getList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelect = array())
 {
     global $DB;
     $arFields = array('ID' => array('FIELD' => 'CPS.ID', 'TYPE' => 'int'), 'TYPE' => array('FIELD' => 'CPS.TYPE', 'TYPE' => 'int'), 'SET_ID' => array('FIELD' => 'CPS.SET_ID', 'TYPE' => 'int'), 'ACTIVE' => array('FIELD' => 'CPS.ACTIVE', 'TYPE' => 'char'), 'OWNER_ID' => array('FIELD' => 'CPS.OWNER_ID', 'TYPE' => 'int'), 'ITEM_ID' => array('FIELD' => 'CPS.ITEM_ID', 'TYPE' => 'int'), 'QUANTITY' => array('FIELD' => 'CPS.QUANTITY', 'TYPE' => 'double'), 'MEASURE' => array('FIELD' => 'CPS.MEASURE', 'TYPE' => 'int'), 'DISCOUNT_PERCENT' => array('FIELD' => 'CPS.DISCOUNT_PERCENT', 'TYPE' => 'double'), 'SORT' => array('FIELD' => 'CPS.SORT', 'TYPE' => 'int'), 'CREATED_BY' => array('FIELD' => 'CPS.CREATED_BY', 'TYPE' => 'int'), 'DATE_CREATE' => array('FIELD' => 'CPS.DATE_CREATE', 'TYPE' => 'datetime'), 'MODIFIED_BY' => array('FIELD' => 'CPS.MODIFIED_BY', 'TYPE' => 'int'), 'TIMESTAMP_X' => array('FIELD' => 'CPS.TIMESTAMP_X', 'TYPE' => 'datetime'), 'XML_ID' => array('FIELD' => 'CPS.XML_ID', 'TYPE' => 'string'));
     $arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelect);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     if (empty($arGroupBy) && is_array($arGroupBy)) {
         $strSql = "select " . $arSqls["SELECT"] . " from b_catalog_product_sets CPS " . $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_product_sets CPS " . $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"];
     }
     $intTopCount = 0;
     $boolNavStartParams = !empty($arNavStartParams) && is_array($arNavStartParams);
     if ($boolNavStartParams && isset($arNavStartParams['nTopCount'])) {
         $intTopCount = (int) $arNavStartParams["nTopCount"];
     }
     if ($boolNavStartParams && 0 >= $intTopCount) {
         $strSql_tmp = "select COUNT('x') as CNT from b_catalog_product_sets CPS " . $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 ($boolNavStartParams && 0 < $intTopCount) {
             $strSql .= " limit " . $intTopCount;
         }
         $dbRes = $DB->Query($strSql, false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__);
     }
     return $dbRes;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:63,代码来源:product_set.php


注:本文中的CCatalog::PrepareSql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。