本文整理汇总了PHP中CSaleOrder::PrepareSql方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleOrder::PrepareSql方法的具体用法?PHP CSaleOrder::PrepareSql怎么用?PHP CSaleOrder::PrepareSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleOrder
的用法示例。
在下文中一共展示了CSaleOrder::PrepareSql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetList
//.........这里部分代码省略.........
* array("SORT" => "ASC"),
* array("PERSON_TYPE_ID" => $PERSON_TYPE),
* false,
* false,
* array()
* );
*
* while ($propsGroup = $db_propsGroup->Fetch())
* {
* echo $propsGroup["NAME"]."<br>";
* }
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleorderpropsgroup/csaleorderpropsgroup__getlist.7a3426ca.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
// To call the old form
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "PG.ID", "TYPE" => "int"), "PERSON_TYPE_ID" => array("FIELD" => "PG.PERSON_TYPE_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "PG.NAME", "TYPE" => "string"), "SORT" => array("FIELD" => "PG.SORT", "TYPE" => "int"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props_group PG " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props_group PG " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_order_props_group PG " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例2: GetBuyersList
public static function GetBuyersList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (empty($arSelectFields) || in_array("*", $arSelectFields)) {
$arSelectFields = array("ID", "ACTIVE", "LID", "DATE_REGISTER", "LOGIN", "EMAIL", "NAME", "LAST_NAME", "SECOND_NAME", "PERSONAL_PHONE", "USER_ID", "LAST_LOGIN", "TIMESTAMP_X", "PERSONAL_BIRTHDAY", "ORDER_COUNT", "ORDER_SUM", "CURRENCY", "LAST_ORDER_DATE");
}
$arFields_m = array("ACTIVE", "LOGIN", "EMAIL", "NAME", "LAST_NAME", "SECOND_NAME", "PERSONAL_PHONE");
$arFields_md = array("LAST_LOGIN", "DATE_REGISTER", "TIMESTAMP_X", "PERSONAL_BIRTHDAY");
$CURRENCY = "";
if (strlen($arFilter["CURRENCY"]) > 0) {
$CURRENCY = $arFilter["CURRENCY"];
unset($arFilter["CURRENCY"]);
} else {
CModule::IncludeModule("currency");
$CURRENCY = CCurrency::GetBaseCurrency();
}
$LID = "";
if (strlen($arFilter["LID"]) > 0) {
$LID = $arFilter["LID"];
unset($arFilter["LID"]);
} else {
$rsSites = CSite::GetList($by = "id", $order = "asc", array("ACTIVE" => "Y"));
$arSite = $rsSites->Fetch();
$LID = $arSite["ID"];
}
$arFields = array("ID" => array("FIELD" => "F.ID", "TYPE" => "int"), "LID" => array("FIELD" => "O1.LID", "TYPE" => "string"), "ORDER_COUNT" => array("FIELD" => "(SELECT COUNT(O3.PRICE) FROM b_sale_order O3 WHERE O3.USER_ID=F.USER_ID AND O3.CURRENCY = '" . $DB->ForSQL($CURRENCY) . "' AND O3.PAYED = 'Y' AND O3.LID = '" . $DB->ForSQL($LID) . "' )", "TYPE" => "double"), "ORDER_SUM" => array("FIELD" => "(SELECT SUM(O3.PRICE) FROM b_sale_order O3 WHERE O3.USER_ID=F.USER_ID AND O3.CURRENCY = '" . $DB->ForSQL($CURRENCY) . "' AND O3.PAYED = 'Y' AND O3.LID = '" . $DB->ForSQL($LID) . "' )", "TYPE" => "double"), "CURRENCY" => array("FIELD" => "O1.CURRENCY", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order O1 ON (O1.USER_ID=U.ID AND O1.CURRENCY = '" . $DB->ForSQL($CURRENCY) . "' AND O1.LID = '" . $DB->ForSQL($LID) . "' AND O1.PAYED = 'Y')"), "LAST_ORDER_DATE" => array("FIELD" => "(SELECT MAX(O2.DATE_INSERT) FROM b_sale_order O2 WHERE (O2.USER_ID=F.USER_ID))", "TYPE" => "datetime"), "NAME_SEARCH" => array("FIELD" => "U.NAME, U.LAST_NAME, U.SECOND_NAME, U.EMAIL, U.LOGIN, U.ID", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (U.ID = F.USER_ID)"), "USER_ID" => array("FIELD" => "F.USER_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_user U ON (U.ID = F.USER_ID)"), "GROUPS_ID" => array("FIELD" => "UG.GROUP_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_user_group UG ON (UG.USER_ID = F.USER_ID)"));
foreach ($arFields_m as $val) {
$arFields[$val] = array("FIELD" => "U." . $val, "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (U.ID = F.USER_ID)");
}
foreach ($arFields_md as $val) {
$arFields[$val] = array("FIELD" => "U." . $val, "TYPE" => "datetime", "FROM" => "INNER JOIN b_user U ON (U.ID = F.USER_ID)");
}
if (!in_array("USER_ID", $arSelectFields)) {
$arSelectFields[] = "USER_ID";
}
$arFilterH = array();
if (!empty($arFilter)) {
foreach ($arFilter as $k => $v) {
if (strpos($k, "ORDER_SUM") !== false || strpos($k, "ORDER_COUNT") !== false || strpos($k, "LAST_ORDER_DATE") !== false) {
$arFilterH[$k] = $v;
unset($arFilter[$k]);
}
}
}
if (!empty($arFilterH)) {
$arSqlsH = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilterH, false, $arSelectFields);
}
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_fuser F " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
$strSql .= "GROUP BY F.USER_ID ";
if (strlen($arSqlsH["WHERE"]) > 0) {
$strSql .= "HAVING " . $arSqlsH["WHERE"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
// echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_fuser F " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
$strSql_tmp .= "GROUP BY F.USER_ID ";
if (strlen($arSqlsH["WHERE"]) > 0) {
$strSql_tmp .= "HAVING " . $arSqlsH["WHERE"] . " ";
}
// echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = $dbRes->SelectedRowsCount();
$dbRes = new CDBResult();
// echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
// echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例3: GetList
//.........这里部分代码省略.........
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalepersontype/csalepersontype__getlist.2dca23fd.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
}
if (empty($arSelectFields)) {
$arSelectFields = array("ID", "LID", "NAME", "SORT", "ACTIVE");
}
if (is_set($arFilter, "LID") && !empty($arFilter["LID"])) {
$arFilter["LIDS"] = $arFilter["LID"];
unset($arFilter["LID"]);
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "PT.ID", "TYPE" => "int"), "LID" => array("FIELD" => "PT.LID", "TYPE" => "string"), "LIDS" => array("FIELD" => "PTS.SITE_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type_site PTS ON (PT.ID = PTS.PERSON_TYPE_ID)"), "NAME" => array("FIELD" => "PT.NAME", "TYPE" => "string"), "SORT" => array("FIELD" => "PT.SORT", "TYPE" => "int"), "ACTIVE" => array("FIELD" => "PT.ACTIVE", "TYPE" => "char"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_person_type PT " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_person_type PT " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_person_type PT " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
示例4: GetList
function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION");
}
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "PERSON_TYPE_ID" => array("FIELD" => "P.PERSON_TYPE_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "P.NAME", "TYPE" => "string"), "TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string"), "REQUIED" => array("FIELD" => "P.REQUIED", "TYPE" => "char"), "REQUIRED" => array("FIELD" => "P.REQUIED", "TYPE" => "char"), "DEFAULT_VALUE" => array("FIELD" => "P.DEFAULT_VALUE", "TYPE" => "string"), "SORT" => array("FIELD" => "P.SORT", "TYPE" => "int"), "USER_PROPS" => array("FIELD" => "P.USER_PROPS", "TYPE" => "char"), "IS_LOCATION" => array("FIELD" => "P.IS_LOCATION", "TYPE" => "char"), "PROPS_GROUP_ID" => array("FIELD" => "P.PROPS_GROUP_ID", "TYPE" => "int"), "SIZE1" => array("FIELD" => "P.SIZE1", "TYPE" => "int"), "SIZE2" => array("FIELD" => "P.SIZE2", "TYPE" => "int"), "DESCRIPTION" => array("FIELD" => "P.DESCRIPTION", "TYPE" => "string"), "IS_EMAIL" => array("FIELD" => "P.IS_EMAIL", "TYPE" => "char"), "IS_PROFILE_NAME" => array("FIELD" => "P.IS_PROFILE_NAME", "TYPE" => "char"), "IS_PAYER" => array("FIELD" => "P.IS_PAYER", "TYPE" => "char"), "IS_LOCATION4TAX" => array("FIELD" => "P.IS_LOCATION4TAX", "TYPE" => "char"), "IS_FILTERED" => array("FIELD" => "P.IS_FILTERED", "TYPE" => "char"), "IS_ZIP" => array("FIELD" => "P.IS_ZIP", "TYPE" => "char"), "CODE" => array("FIELD" => "P.CODE", "TYPE" => "string"), "ACTIVE" => array("FIELD" => "P.ACTIVE", "TYPE" => "char"), "UTIL" => array("FIELD" => "P.UTIL", "TYPE" => "char"), "INPUT_FIELD_LOCATION" => array("FIELD" => "P.INPUT_FIELD_LOCATION", "TYPE" => "int"), "GROUP_ID" => array("FIELD" => "PG.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_PERSON_TYPE_ID" => array("FIELD" => "PG.PERSON_TYPE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_NAME" => array("FIELD" => "PG.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_SORT" => array("FIELD" => "PG.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "PERSON_TYPE_LID" => array("FIELD" => "SPT.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_NAME" => array("FIELD" => "SPT.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_SORT" => array("FIELD" => "SPT.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_ACTIVE" => array("FIELD" => "SPT.ACTIVE", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_order_props P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_order_props P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例5: GetList
/**
* <p>Метод возвращает результат выборки записей информации о временном доступе в соответствии со своими параметрами. Метод динамичный.</p>
*
*
* @param array $arOrder = array() Массив, в соответствии с которым сортируются результирующие
* записи. Массив имеет вид: <pre class="syntax">array( "название_поля1" =>
* "направление_сортировки1", "название_поля2" =>
* "направление_сортировки2", . . . )</pre> В качестве "название_поля<i>N</i>"
* может стоять любое поле информации о временном доступе, а в
* качестве "направление_сортировки<span lang="en-us"><span class="style1">N</span></span>"
* могут быть значения "<i>ASC</i>" (по возрастанию) и "<i>DESC</i>" (по
* убыванию).<br><br> Если массив сортировки имеет несколько элементов,
* то результирующий набор сортируется последовательно по каждому
* элементу (т.е. сначала сортируется по первому элементу, потом
* результат сортируется по второму и т.д.). <br><br> Значение по
* умолчанию - пустой массив array() - означает, что результат
* отсортирован не будет.
*
* @param array $arFilter = array() Массив, в соответствии с которым фильтруются записи информации о
* временном доступе. Массив имеет вид: <pre class="syntax">array(
* "[модификатор1][оператор1]название_поля1" => "значение1",
* "[модификатор2][оператор2]название_поля2" => "значение2", . . . )</pre>
* Удовлетворяющие фильтру записи возвращаются в результате, а
* записи, которые не удовлетворяют условиям фильтра,
* отбрасываются.<br><br> Допустимыми являются следующие модификаторы:
* <ul> <li> <b> !</b> - отрицание;</li> <li> <b> +</b> - значения null, 0 и пустая строка
* так же удовлетворяют условиям фильтра.</li> </ul> Допустимыми
* являются следующие операторы: <ul> <li> <b>>=</b> - значение поля больше
* или равно передаваемой в фильтр величины;</li> <li> <b>></b> - значение
* поля строго больше передаваемой в фильтр величины;</li> <li> <b><=</b> -
* значение поля меньше или равно передаваемой в фильтр величины;</li>
* <li> <b><</b> - значение поля строго меньше передаваемой в фильтр
* величины;</li> <li> <b>@</b> - значение поля находится в передаваемом в
* фильтр разделенном запятой списке значений;</li> <li> <b>~</b> - значение
* поля проверяется на соответствие передаваемому в фильтр
* шаблону;</li> <li> <b>%</b> - значение поля проверяется на соответствие
* передаваемой в фильтр строке в соответствии с языком запросов.</li>
* </ul> В качестве "название_поля<span lang="en-us">N</span>" может стоять любое
* поле информации о временном доступе.<br><br> Пример фильтра: <pre
* class="syntax">array("USER_ID" => 150)</pre> Этот фильтр означает "выбрать все
* записи, в которых значение в поле USER_ID (код пользователя) равно
* 150".<br><br> Значение по умолчанию - пустой массив array() - означает, что
* результат отфильтрован не будет.
*
* @param array $arGroupBy = false Массив полей, по которым группируются записи информации о
* временном доступе. Массив имеет вид: <pre
* class="syntax">array("название_поля1", "группирующая_функция2" =>
* "название_поля2", . . .)</pre> В качестве "название_поля<i>N</i>" может
* стоять любое поле информации о временном доступе. В качестве
* группирующей функции могут стоять: <ul> <li> <b> COUNT</b> - подсчет
* количества;</li> <li> <b>AVG</b> - вычисление среднего значения;</li> <li>
* <b>MIN</b> - вычисление минимального значения;</li> <li> <b> MAX</b> -
* вычисление максимального значения;</li> <li> <b>SUM</b> - вычисление
* суммы.</li> </ul> Если массив пустой, то метод вернет число записей,
* удовлетворяющих фильтру.<br><br> Значение по умолчанию - <i>false</i> -
* означает, что результат группироваться не будет.
*
* @param array $arNavStartParams = false Массив параметров выборки. Может содержать следующие ключи: <ul>
* <li>"<b>nTopCount</b>" - количество возвращаемых методом записей будет
* ограничено сверху значением этого ключа;</li> <li> любой ключ,
* принимаемый методом <b> CDBResult::NavQuery</b> в качестве третьего
* параметра.</li> </ul> Значение по умолчанию - <i>false</i> - означает, что
* параметров выборки нет.
*
* @param array $arSelectFields = array() Массив полей записей, которые будут возвращены методом. Можно
* указать только те поля, которые необходимы. Если в массиве
* присутствует значение "*", то будут возвращены все доступные
* поля.<br><br> Значение по умолчанию - пустой массив array() - означает,
* что будут возвращены все поля основной таблицы запроса.
*
* @return CDBResult <p>Возвращается объект класса CDBResult, содержащий набор
* ассоциативных массивов параметров информации о временном
* доступе с ключами:</p> <ul> <li> <b>ID</b> - код записи; </li> <li> <b>USER_ID</b> - код
* пользователя; </li> <li> <b>ITEM</b> - ресурс, доступ к которому разрешен;
* </li> <li> <b>ITEM_MD5</b> - идентификатор ресурса (строка, однозначно
* идентифицирующая ресурс); </li> <li> <b>TIMESTAMP_X</b> - дата изменения; </li> <li>
* <b>DATE_INSERT</b> - дата вставки записи.</li> </ul> <p>Если в качестве параметра
* arGroupBy передается пустой массив, то метод вернет число записей,
* удовлетворяющих фильтру.</p> <br><br>
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleauxiliary/csaleauxiliary.getlist.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "USER_ID", "TIMESTAMP_X", "ITEM", "ITEM_MD5", "DATE_INSERT");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "A.ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "A.USER_ID", "TYPE" => "int"), "TIMESTAMP_X" => array("FIELD" => "A.TIMESTAMP_X", "TYPE" => "datetime"), "ITEM" => array("FIELD" => "A.ITEM", "TYPE" => "string"), "ITEM_MD5" => array("FIELD" => "A.ITEM_MD5", "TYPE" => "string", "WHERE" => array("CSaleAuxiliary", "PrepareItemMD54Where")), "DATE_INSERT" => array("FIELD" => "A.DATE_INSERT", "TYPE" => "datetime"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_auxiliary A " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
//.........这里部分代码省略.........
示例6: GetList
//.........这里部分代码省略.........
* false,
* array("CURRENT_BUDGET", "CURRENCY")
* );
* while ($arAccountCurrency = $dbAccountCurrency->Fetch())
* {
* echo "На счете ".$arAccountCurrency["CURRENCY"].": ";
* echo SaleFormatCurrency($arAccountCurrency["CURRENT_BUDGET"],
* $arAccountCurrency["CURRENCY"])."<br>";
* }
*
* // Выберем, сумму счетов покупателей (сколько должен магазин покупателям)
* $dbAccountCurrency = CSaleUserAccount::GetList(
* array("CURRENCY" => "ASC"),
* array(),
* array("CURRENCY", "SUM" => "CURRENT_BUDGET"),
* false,
* array("CURRENCY", "SUM" => "CURRENT_BUDGET")
* );
* while ($arAccountCurrency = $dbAccountCurrency->Fetch())
* {
* echo "В валюте ".$arAccountCurrency["CURRENCY"].": ";
* echo SaleFormatCurrency($arAccountCurrency["CURRENT_BUDGET"],
* $arAccountCurrency["CURRENCY"])."<br>";
* }
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleuseraccount/csaleuseraccount.getlist.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "USER_ID", "CURRENT_BUDGET", "CURRENCY", "LOCKED", "NOTES", "TIMESTAMP_X", "DATE_LOCKED");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "UA.ID", "TYPE" => "int"), "USER_ID" => array("FIELD" => "UA.USER_ID", "TYPE" => "int"), "CURRENT_BUDGET" => array("FIELD" => "UA.CURRENT_BUDGET", "TYPE" => "double"), "CURRENCY" => array("FIELD" => "UA.CURRENCY", "TYPE" => "string"), "LOCKED" => array("FIELD" => "UA.LOCKED", "TYPE" => "char"), "NOTES" => array("FIELD" => "UA.NOTES", "TYPE" => "string"), "TIMESTAMP_X" => array("FIELD" => "UA.TIMESTAMP_X", "TYPE" => "datetime"), "DATE_LOCKED" => array("FIELD" => "UA.DATE_LOCKED", "TYPE" => "datetime"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "char", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"), "USER_USER" => array("FIELD" => "U.LOGIN,U.NAME,U.LAST_NAME,U.EMAIL,U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UA.USER_ID = U.ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_user_account UA " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_user_account UA " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_user_account UA " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例7: GetList
//.........这里部分代码省略.........
$arFields = array(
"ID" => array("FIELD" => "UC.ID", "TYPE" => "int"),
"USER_ID" => array("FIELD" => "UC.USER_ID", "TYPE" => "int"),
"ACTIVE" => array("FIELD" => "UC.ACTIVE", "TYPE" => "char"),
"SORT" => array("FIELD" => "UC.SORT", "TYPE" => "int"),
"PAY_SYSTEM_ACTION_ID" => array("FIELD" => "UC.PAY_SYSTEM_ACTION_ID", "TYPE" => "int"),
"CURRENCY" => array("FIELD" => "UC.CURRENCY", "TYPE" => "string"),
"CARD_TYPE" => array("FIELD" => "UC.CARD_TYPE", "TYPE" => "string"),
"CARD_NUM" => array("FIELD" => "UC.CARD_NUM", "TYPE" => "string"),
"CARD_CODE" => array("FIELD" => "UC.CARD_CODE", "TYPE" => "string"),
"CARD_EXP_MONTH" => array("FIELD" => "UC.CARD_EXP_MONTH", "TYPE" => "int"),
"CARD_EXP_YEAR" => array("FIELD" => "UC.CARD_EXP_YEAR", "TYPE" => "int"),
"DESCRIPTION" => array("FIELD" => "UC.DESCRIPTION", "TYPE" => "string"),
"SUM_MIN" => array("FIELD" => "UC.SUM_MIN", "TYPE" => "double"),
"SUM_MAX" => array("FIELD" => "UC.SUM_MAX", "TYPE" => "double"),
"SUM_CURRENCY" => array("FIELD" => "UC.SUM_CURRENCY", "TYPE" => "string"),
"TIMESTAMP_X" => array("FIELD" => "UC.TIMESTAMP_X", "TYPE" => "datetime"),
"LAST_STATUS" => array("FIELD" => "UC.LAST_STATUS", "TYPE" => "char"),
"LAST_STATUS_CODE" => array("FIELD" => "UC.LAST_STATUS_CODE", "TYPE" => "string"),
"LAST_STATUS_DESCRIPTION" => array("FIELD" => "UC.LAST_STATUS_DESCRIPTION", "TYPE" => "string"),
"LAST_STATUS_MESSAGE" => array("FIELD" => "UC.LAST_STATUS_MESSAGE", "TYPE" => "string"),
"LAST_SUM" => array("FIELD" => "UC.LAST_SUM", "TYPE" => "double"),
"LAST_CURRENCY" => array("FIELD" => "UC.LAST_CURRENCY", "TYPE" => "string"),
"LAST_DATE" => array("FIELD" => "UC.LAST_DATE", "TYPE" => "datetime"),
"USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UC.USER_ID = U.ID)"),
"USER_ACTIVE" => array("FIELD" => "U.ACTIVE", "TYPE" => "char", "FROM" => "INNER JOIN b_user U ON (UC.USER_ID = U.ID)"),
"USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UC.USER_ID = U.ID)"),
"USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UC.USER_ID = U.ID)"),
"USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UC.USER_ID = U.ID)"),
"USER_USER" => array("FIELD" => "U.LOGIN,U.NAME,U.LAST_NAME,U.EMAIL,U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (UC.USER_ID = U.ID)")
);
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy)==0)
{
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
"FROM b_sale_user_cards UC ".
" ".$arSqls["FROM"]." ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
return $arRes["CNT"];
else
return False;
}
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
"FROM b_sale_user_cards UC ".
" ".$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)
示例8: GetList
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "SITE_ID", "USER_ID", "AFFILIATE_ID", "PLAN_ID", "ACTIVE", "TIMESTAMP_X", "DATE_CREATE", "PAID_SUM", "APPROVED_SUM", "PENDING_SUM", "ITEMS_NUMBER", "ITEMS_SUM", "LAST_CALCULATE", "AFF_SITE", "AFF_DESCRIPTION", "FIX_PLAN");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "A.ID", "TYPE" => "int"), "SITE_ID" => array("FIELD" => "A.SITE_ID", "TYPE" => "string"), "USER_ID" => array("FIELD" => "A.USER_ID", "TYPE" => "int"), "AFFILIATE_ID" => array("FIELD" => "A.AFFILIATE_ID", "TYPE" => "int"), "PLAN_ID" => array("FIELD" => "A.PLAN_ID", "TYPE" => "int"), "ACTIVE" => array("FIELD" => "A.ACTIVE", "TYPE" => "char"), "TIMESTAMP_X" => array("FIELD" => "A.TIMESTAMP_X", "TYPE" => "datetime"), "DATE_CREATE" => array("FIELD" => "A.DATE_CREATE", "TYPE" => "datetime"), "PAID_SUM" => array("FIELD" => "A.PAID_SUM", "TYPE" => "double"), "APPROVED_SUM" => array("FIELD" => "A.APPROVED_SUM", "TYPE" => "double"), "PENDING_SUM" => array("FIELD" => "A.PENDING_SUM", "TYPE" => "double"), "ITEMS_NUMBER" => array("FIELD" => "A.ITEMS_NUMBER", "TYPE" => "int"), "ITEMS_SUM" => array("FIELD" => "A.ITEMS_SUM", "TYPE" => "double"), "LAST_CALCULATE" => array("FIELD" => "A.LAST_CALCULATE", "TYPE" => "datetime"), "AFF_SITE" => array("FIELD" => "A.AFF_SITE", "TYPE" => "string"), "AFF_DESCRIPTION" => array("FIELD" => "A.AFF_DESCRIPTION", "TYPE" => "string"), "FIX_PLAN" => array("FIELD" => "A.FIX_PLAN", "TYPE" => "char"), "PLAN_SITE_ID" => array("FIELD" => "AP.SITE_ID", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_NAME" => array("FIELD" => "AP.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_DESCRIPTION" => array("FIELD" => "AP.DESCRIPTION", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_TIMESTAMP_X" => array("FIELD" => "AP.TIMESTAMP_X", "TYPE" => "datetime", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_ACTIVE" => array("FIELD" => "AP.ACTIVE", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_BASE_RATE" => array("FIELD" => "AP.BASE_RATE", "TYPE" => "double", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_BASE_RATE_TYPE" => array("FIELD" => "AP.BASE_RATE_TYPE", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_BASE_RATE_CURRENCY" => array("FIELD" => "AP.BASE_RATE_CURRENCY", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_MIN_PAY" => array("FIELD" => "AP.MIN_PAY", "TYPE" => "double", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "PLAN_MIN_PLAN_VALUE" => array("FIELD" => "AP.MIN_PLAN_VALUE", "TYPE" => "double", "FROM" => "INNER JOIN b_sale_affiliate_plan AP ON (A.PLAN_ID = AP.ID)"), "USER_LOGIN" => array("FIELD" => "U.LOGIN", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (A.USER_ID = U.ID)"), "USER_NAME" => array("FIELD" => "U.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (A.USER_ID = U.ID)"), "USER_LAST_NAME" => array("FIELD" => "U.LAST_NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (A.USER_ID = U.ID)"), "USER_EMAIL" => array("FIELD" => "U.EMAIL", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (A.USER_ID = U.ID)"), "USER_USER" => array("FIELD" => "U.LOGIN,U.NAME,U.LAST_NAME,U.EMAIL,U.ID", "WHERE_ONLY" => "Y", "TYPE" => "string", "FROM" => "INNER JOIN b_user U ON (A.USER_ID = U.ID)"), "ORDER_ID" => array("FIELD" => "O.ID", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order O ON (A.ID = O.AFFILIATE_ID)"), "ORDER_DATE_ALLOW_DELIVERY" => array("FIELD" => "O.DATE_ALLOW_DELIVERY", "TYPE" => "datetime", "FROM" => "INNER JOIN b_sale_order O ON (A.ID = O.AFFILIATE_ID)"), "ORDER_ALLOW_DELIVERY" => array("FIELD" => "O.ALLOW_DELIVERY", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order O ON (A.ID = O.AFFILIATE_ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_affiliate A " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_affiliate A " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_affiliate A " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例9: GetPermissionsList
function GetPermissionsList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "S.ID", "TYPE" => "int"), "GROUP_ID" => array("FIELD" => "S.GROUP_ID", "TYPE" => "int"), "STATUS_ID" => array("FIELD" => "S.STATUS_ID", "TYPE" => "char"), "PERM_VIEW" => array("FIELD" => "S.PERM_VIEW", "TYPE" => "char"), "PERM_CANCEL" => array("FIELD" => "S.PERM_CANCEL", "TYPE" => "char"), "PERM_MARK" => array("FIELD" => "S.PERM_MARK", "TYPE" => "char"), "PERM_DELIVERY" => array("FIELD" => "S.PERM_DELIVERY", "TYPE" => "char"), "PERM_DEDUCTION" => array("FIELD" => "S.PERM_DEDUCTION", "TYPE" => "char"), "PERM_PAYMENT" => array("FIELD" => "S.PERM_PAYMENT", "TYPE" => "char"), "PERM_STATUS" => array("FIELD" => "S.PERM_STATUS", "TYPE" => "char"), "PERM_STATUS_FROM" => array("FIELD" => "S.PERM_STATUS_FROM", "TYPE" => "char"), "PERM_UPDATE" => array("FIELD" => "S.PERM_UPDATE", "TYPE" => "char"), "PERM_DELETE" => array("FIELD" => "S.PERM_DELETE", "TYPE" => "char"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_status2group S " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_status2group S " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_status2group S " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// FOR MYSQL!!! ANOTHER CODE FOR ORACLE
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例10: GetList
function GetList($arOrder = array("SORT"=>"ASC", "COUNTRY_NAME_LANG"=>"ASC", "CITY_NAME_LANG"=>"ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (is_string($arGroupBy) && strlen($arGroupBy) == 2)
{
$arFilter["LID"] = $arGroupBy;
$arGroupBy = false;
$arSelectFields = array("ID", "COUNTRY_ID", "REGION_ID", "CITY_ID", "SORT", "COUNTRY_NAME_ORIG", "COUNTRY_SHORT_NAME", "COUNTRY_NAME_LANG", "CITY_NAME_ORIG", "CITY_SHORT_NAME", "CITY_NAME_LANG", "REGION_NAME_ORIG", "REGION_SHORT_NAME", "REGION_NAME_LANG", "COUNTRY_NAME", "CITY_NAME", "REGION_NAME", "LOC_DEFAULT");
}
if (count($arSelectFields) <= 0)
$arSelectFields = array("ID", "COUNTRY_ID", "REGION_ID", "CITY_ID", "SORT", "COUNTRY_NAME_ORIG", "COUNTRY_SHORT_NAME", "REGION_NAME_ORIG", "CITY_NAME_ORIG", "REGION_SHORT_NAME", "CITY_SHORT_NAME", "COUNTRY_LID", "COUNTRY_NAME", "REGION_LID", "CITY_LID", "REGION_NAME", "CITY_NAME", "LOC_DEFAULT");
$additionalFilter = "";
if (isset($arFilter["LID"]) || strlen($arFilter["LID"]) > 0)
{
$additionalFilterLCL = " AND LCL.LID = '".$DB->ForSql($arFilter["LID"], 2)."'";
$additionalFilterLRL = " AND LRL.LID = '".$DB->ForSql($arFilter["LID"], 2)."'";
$additionalFilterLGL = " AND LGL.LID = '".$DB->ForSql($arFilter["LID"], 2)."'";
}
// FIELDS -->
$arFields = array(
"ID" => array("FIELD" => "L.ID", "TYPE" => "int"),
"LOC_DEFAULT" => array("FIELD" => "L.LOC_DEFAULT", "TYPE" => "string"),
"COUNTRY_ID" => array("FIELD" => "L.COUNTRY_ID", "TYPE" => "int"),
"CITY_ID" => array("FIELD" => "L.CITY_ID", "TYPE" => "int"),
"REGION_ID" => array("FIELD" => "L.REGION_ID", "TYPE" => "int"),
"SORT" => array("FIELD" => "L.SORT", "TYPE" => "int"),
"COUNTRY_NAME_ORIG" => array("FIELD" => "LC.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country LC ON (L.COUNTRY_ID = LC.ID)"),
"COUNTRY_SHORT_NAME" => array("FIELD" => "LC.SHORT_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country LC ON (L.COUNTRY_ID = LC.ID)"),
"CITY_NAME_ORIG" => array("FIELD" => "LG.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city LG ON (L.CITY_ID = LG.ID)"),
"CITY_SHORT_NAME" => array("FIELD" => "LG.SHORT_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city LG ON (L.CITY_ID = LG.ID)"),
"REGION_NAME_ORIG" => array("FIELD" => "LR.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region LR ON (L.REGION_ID = LR.ID)"),
"REGION_SHORT_NAME" => array("FIELD" => "LR.SHORT_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region LR ON (L.REGION_ID = LR.ID)"),
"COUNTRY_LID" => array("FIELD" => "LCL.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country_lang LCL ON (L.COUNTRY_ID = LCL.COUNTRY_ID".$additionalFilterLCL.")"),
"COUNTRY_NAME" => array("FIELD" => "LCL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country_lang LCL ON (L.COUNTRY_ID = LCL.COUNTRY_ID".$additionalFilterLCL.")"),
"COUNTRY_NAME_LANG" => array("FIELD" => "LCL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country_lang LCL ON (L.COUNTRY_ID = LCL.COUNTRY_ID".$additionalFilterLCL.")"),
"COUNTRY_SHORT_NAME_LANG" => array("FIELD" => "LCL.SHORT_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country_lang LCL ON (L.COUNTRY_ID = LCL.COUNTRY_ID".$additionalFilterLCL.")"),
"REGION_LID" => array("FIELD" => "LRL.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region_lang LRL ON (L.REGION_ID = LRL.REGION_ID".$additionalFilterLRL.")"),
"REGION_NAME" => array("FIELD" => "LRL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region_lang LRL ON (L.REGION_ID = LRL.REGION_ID".$additionalFilterLRL.")"),
"REGION_NAME_LANG" => array("FIELD" => "LRL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region_lang LRL ON (L.REGION_ID = LRL.REGION_ID".$additionalFilterLRL.")"),
"REGION_SHORT_NAME_LANG" => array("FIELD" => "LRL.SHORT_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region_lang LRL ON (L.REGION_ID = LRL.REGION_ID".$additionalFilterLRL.")"),
"CITY_LID" => array("FIELD" => "LGL.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city_lang LGL ON (L.CITY_ID = LGL.CITY_ID".$additionalFilterLGL.")"),
"CITY_NAME" => array("FIELD" => "LGL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city_lang LGL ON (L.CITY_ID = LGL.CITY_ID".$additionalFilterLGL.")"),
"CITY_NAME_LANG" => array("FIELD" => "LGL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city_lang LGL ON (L.CITY_ID = LGL.CITY_ID".$additionalFilterLGL.")"),
"CITY_SHORT_NAME_LANG" => array("FIELD" => "LGL.SHORT_NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city_lang LGL ON (L.CITY_ID = LGL.CITY_ID".$additionalFilterLGL.")"),
"COUNTRY" => array("FIELD" => "LCL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_country_lang LCL ON (L.COUNTRY_ID = LCL.COUNTRY_ID".$additionalFilterLCL.")"),
"CITY" => array("FIELD" => "LGL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_city_lang LGL ON (L.CITY_ID = LGL.CITY_ID".$additionalFilterLGL.")"),
"REGION" => array("FIELD" => "LRL.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_location_region_lang LRL ON (L.REGION_ID = LRL.REGION_ID".$additionalFilterLRL.")")
);
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy)==0)
{
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
"FROM b_sale_location L ".
" ".$arSqls["FROM"]." ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
return $arRes["CNT"];
else
return False;
}
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
"FROM b_sale_location L ".
" ".$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 =
//.........这里部分代码省略.........
示例11: GetList
/**
* The function select viewed product
*
* @param array $arOrder - array to sort
* @param array $arFilter - array to filter
* @param array $arGroupBy - array to group records
* @param array $arNavStartParams - array to parameters
* @param array $arSelectFields - array to selectes fields
* @return object $dbRes - object result
*/
static public function GetList($arOrder = array("ID"=>"DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (array_key_exists("DATE_FROM", $arFilter))
{
$arFilter[">=DATE_VISIT"] = trim($arFilter["DATE_FROM"]);
unset($arFilter["DATE_FROM"]);
}
if (array_key_exists("DATE_TO", $arFilter))
{
$arFilter["<=DATE_VISIT"] = trim($arFilter["DATE_TO"]);
unset($arFilter["DATE_TO"]);
}
if (!$arSelectFields || count($arSelectFields) <= 0 || in_array("*", $arSelectFields))
$arSelectFields = array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "MODULE", "LID", "NAME", "DETAIL_PAGE_URL", "CURRENCY", "PRICE", "NOTES", "PREVIEW_PICTURE", "DETAIL_PICTURE", "CALLBACK_FUNC");
$arFields = array(
"ID" => array("FIELD" => "V.ID", "TYPE" => "int"),
"FUSER_ID" => array("FIELD" => "V.FUSER_ID", "TYPE" => "int"),
"DATE_VISIT" => array("FIELD" => "V.DATE_VISIT", "TYPE" => "datetime"),
"PRODUCT_ID" => array("FIELD" => "V.PRODUCT_ID", "TYPE" => "int"),
"MODULE" => array("FIELD" => "V.MODULE", "TYPE" => "string"),
"LID" => array("FIELD" => "V.LID", "TYPE" => "string"),
"NAME" => array("FIELD" => "V.NAME", "TYPE" => "string"),
"DETAIL_PAGE_URL" => array("FIELD" => "V.DETAIL_PAGE_URL", "TYPE" => "string"),
"CURRENCY" => array("FIELD" => "V.CURRENCY", "TYPE" => "string"),
"PRICE" => array("FIELD" => "V.PRICE", "TYPE" => "double"),
"NOTES" => array("FIELD" => "V.NOTES", "TYPE" => "string"),
"PREVIEW_PICTURE" => array("FIELD" => "V.PREVIEW_PICTURE", "TYPE" => "string"),
"DETAIL_PICTURE" => array("FIELD" => "V.DETAIL_PICTURE", "TYPE" => "string"),
"CALLBACK_FUNC" => array("FIELD" => "V.CALLBACK_FUNC", "TYPE" => "string"),
);
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
$strSql =
"SELECT ".$arSqls["SELECT"]." ".
"FROM b_sale_viewed_product V ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql .= "WHERE ".$arSqls["WHERE"]." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql .= "GROUP BY ".$arSqls["GROUPBY"]." ";
if (strlen($arSqls["ORDERBY"]) > 0)
$strSql .= "ORDER BY ".$arSqls["ORDERBY"]." ";
if (is_array($arGroupBy) && count($arGroupBy) == 0)
{
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
return $arRes["CNT"];
else
return false;
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0 )
{
$strSql_tmp =
"SELECT COUNT('x') as CNT ".
"FROM b_sale_viewed_product B ";
if (strlen($arSqls["WHERE"]) > 0)
$strSql_tmp .= "WHERE ".$arSqls["WHERE"]." ";
if (strlen($arSqls["GROUPBY"]) > 0)
$strSql_tmp .= "GROUP BY ".$arSqls["GROUPBY"]." ";
$dbRes = $DB->Query($strSql_tmp, false, "File: ".__FILE__."<br>Line: ".__LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0)
{
if ($arRes = $dbRes->Fetch())
$cnt = $arRes["CNT"];
}
else
{
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
}
else
{
$strSql = $DB->TopSql($strSql, $arNavStartParams["nTopCount"]);
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
}
//.........这里部分代码省略.........
示例12: GetList
//.........这里部分代码省略.........
* <pre>
* // Выведем все свойства профиля покупателя с кодом $ID
* $db_propVals = CSaleOrderUserPropsValue::GetList(array("ID" => "ASC"), Array("USER_PROPS_ID"=>$ID));
* while ($arPropVals = $db_propVals->Fetch())
* {
* echo $arPropVals["USER_VALUE_NAME"]."=".$arPropVals["VALUE"]."<br>";
* }
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csaleorderuserpropsvalue/csaleorderuserpropsvalue__getlist.19b444a8.php
* @author Bitrix
*/
public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (!is_array($arOrder) && !is_array($arFilter)) {
$arOrder = strval($arOrder);
$arFilter = strval($arFilter);
if (strlen($arOrder) > 0 && strlen($arFilter) > 0) {
$arOrder = array($arOrder => $arFilter);
} else {
$arOrder = array();
}
if (is_array($arGroupBy)) {
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "USER_PROPS_ID", "ORDER_PROPS_ID", "USER_VALUE_NAME", "VALUE", "TYPE", "SORT", "VARIANT_NAME", "CODE");
}
}
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "USER_PROPS_ID", "ORDER_PROPS_ID", "NAME", "VALUE", "PROP_ID", "PROP_PERSON_TYPE_ID", "PROP_NAME", "PROP_TYPE", "PROP_REQUIED", "PROP_DEFAULT_VALUE", "PROP_SORT", "PROP_USER_PROPS", "PROP_IS_LOCATION", "PROP_PROPS_GROUP_ID", "PROP_SIZE1", "PROP_SIZE2", "PROP_DESCRIPTION", "PROP_IS_EMAIL", "PROP_IS_PROFILE_NAME", "PROP_IS_PAYER", "PROP_IS_LOCATION4TAX", "PROP_IS_ZIP", "PROP_CODE", "VARIANT_ID", "VARIANT_ORDER_PROPS_ID", "VARIANT_NAME", "VARIANT_VALUE", "VARIANT_SORT", "VARIANT_DESCRIPTION");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "UP.ID", "TYPE" => "int"), "USER_PROPS_ID" => array("FIELD" => "UP.USER_PROPS_ID", "TYPE" => "int"), "ORDER_PROPS_ID" => array("FIELD" => "UP.ORDER_PROPS_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "UP.NAME", "TYPE" => "string"), "VALUE" => array("FIELD" => "UP.VALUE", "TYPE" => "string"), "PROP_ID" => array("FIELD" => "P.ID", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_PERSON_TYPE_ID" => array("FIELD" => "P.PERSON_TYPE_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_NAME" => array("FIELD" => "P.NAME", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_REQUIED" => array("FIELD" => "P.REQUIED", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_DEFAULT_VALUE" => array("FIELD" => "P.DEFAULT_VALUE", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_SORT" => array("FIELD" => "P.SORT", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_USER_PROPS" => array("FIELD" => "P.USER_PROPS", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_IS_LOCATION" => array("FIELD" => "P.IS_LOCATION", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_PROPS_GROUP_ID" => array("FIELD" => "P.PROPS_GROUP_ID", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_SIZE1" => array("FIELD" => "P.SIZE1", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_SIZE2" => array("FIELD" => "P.SIZE2", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_DESCRIPTION" => array("FIELD" => "P.DESCRIPTION", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_IS_EMAIL" => array("FIELD" => "P.IS_EMAIL", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_IS_PROFILE_NAME" => array("FIELD" => "P.IS_PROFILE_NAME", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_IS_PAYER" => array("FIELD" => "P.IS_PAYER", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_IS_LOCATION4TAX" => array("FIELD" => "P.IS_LOCATION4TAX", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_IS_ZIP" => array("FIELD" => "P.IS_ZIP", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_CODE" => array("FIELD" => "P.CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_ACTIVE" => array("FIELD" => "P.ACTIVE", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "PROP_UTIL" => array("FIELD" => "P.UTIL", "TYPE" => "char", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "VARIANT_ID" => array("FIELD" => "PV.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_variant PV ON (UP.ORDER_PROPS_ID = PV.ORDER_PROPS_ID AND UP.VALUE = PV.VALUE)"), "VARIANT_ORDER_PROPS_ID" => array("FIELD" => "PV.ORDER_PROPS_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_variant PV ON (UP.ORDER_PROPS_ID = PV.ORDER_PROPS_ID AND UP.VALUE = PV.VALUE)"), "VARIANT_NAME" => array("FIELD" => "PV.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_variant PV ON (UP.ORDER_PROPS_ID = PV.ORDER_PROPS_ID AND UP.VALUE = PV.VALUE)"), "VARIANT_VALUE" => array("FIELD" => "PV.VALUE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_variant PV ON (UP.ORDER_PROPS_ID = PV.ORDER_PROPS_ID AND UP.VALUE = PV.VALUE)"), "VARIANT_SORT" => array("FIELD" => "PV.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_variant PV ON (UP.ORDER_PROPS_ID = PV.ORDER_PROPS_ID AND UP.VALUE = PV.VALUE)"), "VARIANT_DESCRIPTION" => array("FIELD" => "PV.DESCRIPTION", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_variant PV ON (UP.ORDER_PROPS_ID = PV.ORDER_PROPS_ID AND UP.VALUE = PV.VALUE)"), "USER_VALUE_NAME" => array("FIELD" => "PV.NAME", "TYPE" => "string"), "TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "SORT" => array("FIELD" => "P.SORT", "TYPE" => "int", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"), "CODE" => array("FIELD" => "P.CODE", "TYPE" => "string", "FROM" => "INNER JOIN b_sale_order_props P ON (UP.ORDER_PROPS_ID = P.ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_user_props_value UP " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_user_props_value UP " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_user_props_value UP " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// ТОЛЬКО ДЛЯ MYSQL!!! ДЛЯ ORACLE ДРУГОЙ КОД
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例13: GetList
function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
if (isset($arFilter["PERSON_TYPE_ID"])) {
$arFilter["PSA_PERSON_TYPE_ID"] = $arFilter["PERSON_TYPE_ID"];
unset($arFilter["PERSON_TYPE_ID"]);
if (count($arSelectFields) <= 0) {
$arSelectFields = array("*");
}
}
if (count($arSelectFields) <= 0) {
$arSelectFields = array("ID", "LID", "CURRENCY", "NAME", "ACTIVE", "SORT", "DESCRIPTION");
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "LID" => array("FIELD" => "P.LID", "TYPE" => "string"), "CURRENCY" => array("FIELD" => "P.CURRENCY", "TYPE" => "string"), "NAME" => array("FIELD" => "P.NAME", "TYPE" => "string"), "ACTIVE" => array("FIELD" => "P.ACTIVE", "TYPE" => "char"), "SORT" => array("FIELD" => "P.SORT", "TYPE" => "int"), "DESCRIPTION" => array("FIELD" => "P.DESCRIPTION", "TYPE" => "string"), "PSA_ID" => array("FIELD" => "PA.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_NAME" => array("FIELD" => "PA.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_ACTION_FILE" => array("FIELD" => "PA.ACTION_FILE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_RESULT_FILE" => array("FIELD" => "PA.RESULT_FILE", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_NEW_WINDOW" => array("FIELD" => "PA.NEW_WINDOW", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_PERSON_TYPE_ID" => array("FIELD" => "PA.PERSON_TYPE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_PARAMS" => array("FIELD" => "PA.PARAMS", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_HAVE_PAYMENT" => array("FIELD" => "PA.HAVE_PAYMENT", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_HAVE_ACTION" => array("FIELD" => "PA.HAVE_ACTION", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_HAVE_RESULT" => array("FIELD" => "PA.HAVE_RESULT", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_HAVE_PREPAY" => array("FIELD" => "PA.HAVE_PREPAY", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_HAVE_RESULT_RECEIVE" => array("FIELD" => "PA.HAVE_RESULT_RECEIVE", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_ENCODING" => array("FIELD" => "PA.ENCODING", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"), "PSA_LOGOTIP" => array("FIELD" => "PA.LOGOTIP", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_pay_system_action PA ON (P.ID = PA.PAY_SYSTEM_ID)"));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
$arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "DISTINCT", $arSqls["SELECT"]);
if (is_array($arGroupBy) && count($arGroupBy) == 0) {
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_pay_system P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!1!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($arRes = $dbRes->Fetch()) {
return $arRes["CNT"];
} else {
return False;
}
}
$strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_pay_system P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
if (strlen($arSqls["ORDERBY"]) > 0) {
$strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
}
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
$strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_pay_system P " . "\t" . $arSqls["FROM"] . " ";
if (strlen($arSqls["WHERE"]) > 0) {
$strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
}
if (strlen($arSqls["GROUPBY"]) > 0) {
$strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
}
//echo "!2.1!=".htmlspecialcharsbx($strSql_tmp)."<br>";
$dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$cnt = 0;
if (strlen($arSqls["GROUPBY"]) <= 0) {
if ($arRes = $dbRes->Fetch()) {
$cnt = $arRes["CNT"];
}
} else {
// рнкэйн дкъ MYSQL!!! дкъ ORACLE дпсцни йнд
$cnt = $dbRes->SelectedRowsCount();
}
$dbRes = new CDBResult();
//echo "!2.2!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
} else {
if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) > 0) {
$strSql .= "LIMIT " . IntVal($arNavStartParams["nTopCount"]);
}
//echo "!3!=".htmlspecialcharsbx($strSql)."<br>";
$dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $dbRes;
}
示例14: GetPermissionsList
function GetPermissionsList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
global $DB;
$arFields = array("ID" => array("FIELD" => "S.ID", "TYPE" => "int"), "GROUP_ID" => array("FIELD" => "S.GROUP_ID", "TYPE" => "int"), "STATUS_ID" => array("FIELD" => "S.STATUS_ID", "TYPE" => "char"), "PERM_VIEW" => array("FIELD" => "S.PERM_VIEW", "TYPE" => "char"), "PERM_CANCEL" => array("FIELD" => "S.PERM_CANCEL", "TYPE" => "char"), "PERM_MARK" => array("FIELD" => "S.PERM_MARK", "TYPE" => "char"), "PERM_DELIVERY" => array("FIELD" => "S.PERM_DELIVERY", "TYPE" => "char"), "PERM_DEDUCTION" => array("FIELD" => "S.PERM_DEDUCTION", "TYPE" => "char"), "PERM_PAYMENT" => array("FIELD" => "S.PERM_PAYMENT", "TYPE" => "char"), "PERM_STATUS" => array("FIELD" => "S.PERM_STATUS", "TYPE" => "char"), "PERM_STATUS_FROM" => array("FIELD" => "S.PERM_STATUS_FROM", "TYPE" => "char"), "PERM_UPDATE" => array("FIELD" => "S.PERM_UPDATE", "TYPE" => "char"), "PERM_DELETE" => array("FIELD" => "S.PERM_DELETE", "TYPE" => "char"));
$arSqls = CSaleOrder::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_sale_status2group S " . $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_sale_status2group S " . $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_sale_status2group S " . $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;
}
示例15: GetList
//.........这里部分代码省略.........
$arFilter = $arGroupBy;
} else {
$arFilter = array();
}
$arGroupBy = false;
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION", "MULTIPLE", "PAYSYSTEM_ID", "DELIVERY_ID");
}
if (empty($arSelectFields)) {
$arSelectFields = array("ID", "PERSON_TYPE_ID", "NAME", "TYPE", "REQUIED", "DEFAULT_VALUE", "SORT", "USER_PROPS", "IS_LOCATION", "PROPS_GROUP_ID", "SIZE1", "SIZE2", "DESCRIPTION", "IS_EMAIL", "IS_PROFILE_NAME", "IS_PAYER", "IS_LOCATION4TAX", "IS_ZIP", "CODE", "IS_FILTERED", "ACTIVE", "UTIL", "INPUT_FIELD_LOCATION", "MULTIPLE", "PAYSYSTEM_ID", "DELIVERY_ID");
}
// filter by relation to delivery and payment systems
if (isset($arFilter["RELATED"]) && !is_array($arFilter["RELATED"]) && intval($arFilter["RELATED"]) == 0) {
if (($key = array_search("PAYSYSTEM_ID", $arSelectFields)) !== false) {
unset($arSelectFields[$key]);
}
if (($key = array_search("DELIVERY_ID", $arSelectFields)) !== false) {
unset($arSelectFields[$key]);
}
} else {
if (isset($arFilter["RELATED"]) && is_array($arFilter["RELATED"])) {
if (isset($arFilter["RELATED"]["PAYSYSTEM_ID"])) {
$arFilter["PAYSYSTEM_ID"] = $arFilter["RELATED"]["PAYSYSTEM_ID"];
unset($arFilter["RELATED"]["PAYSYSTEM_ID"]);
}
if (isset($arFilter["RELATED"]["DELIVERY_ID"])) {
$arFilter["DELIVERY_ID"] = $arFilter["RELATED"]["DELIVERY_ID"];
unset($arFilter["RELATED"]["DELIVERY_ID"]);
}
}
}
// FIELDS -->
$arFields = array("ID" => array("FIELD" => "P.ID", "TYPE" => "int"), "PERSON_TYPE_ID" => array("FIELD" => "P.PERSON_TYPE_ID", "TYPE" => "int"), "NAME" => array("FIELD" => "P.NAME", "TYPE" => "string"), "TYPE" => array("FIELD" => "P.TYPE", "TYPE" => "string"), "REQUIED" => array("FIELD" => "P.REQUIED", "TYPE" => "char"), "REQUIRED" => array("FIELD" => "P.REQUIED", "TYPE" => "char"), "DEFAULT_VALUE" => array("FIELD" => "P.DEFAULT_VALUE", "TYPE" => "string"), "SORT" => array("FIELD" => "P.SORT", "TYPE" => "int"), "USER_PROPS" => array("FIELD" => "P.USER_PROPS", "TYPE" => "char"), "IS_LOCATION" => array("FIELD" => "P.IS_LOCATION", "TYPE" => "char"), "PROPS_GROUP_ID" => array("FIELD" => "P.PROPS_GROUP_ID", "TYPE" => "int"), "SIZE1" => array("FIELD" => "P.SIZE1", "TYPE" => "int"), "SIZE2" => array("FIELD" => "P.SIZE2", "TYPE" => "int"), "DESCRIPTION" => array("FIELD" => "P.DESCRIPTION", "TYPE" => "string"), "IS_EMAIL" => array("FIELD" => "P.IS_EMAIL", "TYPE" => "char"), "IS_PROFILE_NAME" => array("FIELD" => "P.IS_PROFILE_NAME", "TYPE" => "char"), "IS_PAYER" => array("FIELD" => "P.IS_PAYER", "TYPE" => "char"), "IS_LOCATION4TAX" => array("FIELD" => "P.IS_LOCATION4TAX", "TYPE" => "char"), "IS_FILTERED" => array("FIELD" => "P.IS_FILTERED", "TYPE" => "char"), "IS_ZIP" => array("FIELD" => "P.IS_ZIP", "TYPE" => "char"), "CODE" => array("FIELD" => "P.CODE", "TYPE" => "string"), "ACTIVE" => array("FIELD" => "P.ACTIVE", "TYPE" => "char"), "UTIL" => array("FIELD" => "P.UTIL", "TYPE" => "char"), "INPUT_FIELD_LOCATION" => array("FIELD" => "P.INPUT_FIELD_LOCATION", "TYPE" => "int"), "MULTIPLE" => array("FIELD" => "P.MULTIPLE", "TYPE" => "char"), "GROUP_ID" => array("FIELD" => "PG.ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_PERSON_TYPE_ID" => array("FIELD" => "PG.PERSON_TYPE_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_NAME" => array("FIELD" => "PG.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "GROUP_SORT" => array("FIELD" => "PG.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_group PG ON (P.PROPS_GROUP_ID = PG.ID)"), "PERSON_TYPE_LID" => array("FIELD" => "SPT.LID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_NAME" => array("FIELD" => "SPT.NAME", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_SORT" => array("FIELD" => "SPT.SORT", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PERSON_TYPE_ACTIVE" => array("FIELD" => "SPT.ACTIVE", "TYPE" => "char", "FROM" => "LEFT JOIN b_sale_person_type SPT ON (P.PERSON_TYPE_ID = SPT.ID)"), "PAYSYSTEM_ID" => array("FIELD" => "SOP.PROPERTY_ID", "TYPE" => "int", "FROM" => "LEFT JOIN b_sale_order_props_relation SOP ON P.ID = SOP.PROPERTY_ID", "WHERE" => array("CSaleOrderProps", "PrepareRelation4Where")), "DELIVERY_ID" => array("FIELD" => "SOD.PROPERTY_ID", "TYPE" => "string", "FROM" => "LEFT JOIN b_sale_order_props_relation SOD ON P.ID = SOD.PROPERTY_ID", "WHERE" => array("CSaleOrderProps", "PrepareRelation4Where")));
// <-- FIELDS
$arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
//filter order properties by relation to delivery and payment systems
if (isset($arFilter["RELATED"])) {
if (!is_array($arFilter["RELATED"]) && intval($arFilter["RELATED"]) == 0) {
if (strlen($arSqls["WHERE"]) > 0) {
$arSqls["WHERE"] .= " AND ";
}
$arSqls["WHERE"] .= "(P.ID NOT IN (SELECT DISTINCT SOR.PROPERTY_ID FROM b_sale_order_props_relation SOR))";
} elseif (is_array($arFilter["RELATED"])) {
$strSqlRelatedWhere = "";
// payment
if (isset($arFilter["PAYSYSTEM_ID"]) && intval($arFilter["PAYSYSTEM_ID"]) > 0) {
$strSqlRelatedWhere .= "(SOP.ENTITY_TYPE = 'P' AND SOP.ENTITY_ID = " . $DB->ForSql($arFilter["PAYSYSTEM_ID"]) . ")";
}
// delivery
if (isset($arFilter["DELIVERY_ID"]) && strlen($arFilter["DELIVERY_ID"]) > 0) {
if (strlen($strSqlRelatedWhere) > 0) {
$logic = "OR";
if (isset($arFilter["RELATED"]["LOGIC"]) && $arFilter["RELATED"]["LOGIC"] == "AND") {
$logic = "AND";
}
$strSqlRelatedWhere .= " " . $logic . " ";
}
$strSqlRelatedWhere .= "(SOD.ENTITY_TYPE = 'D' AND SOD.ENTITY_ID = '" . $DB->ForSql($arFilter["DELIVERY_ID"]) . "')";
}
// all other
if (isset($arFilter["RELATED"]["TYPE"])) {
if ($arFilter["RELATED"]["TYPE"] == "WITH_NOT_RELATED") {
if (strlen($strSqlRelatedWhere) > 0) {
$strSqlRelatedWhere .= " OR (P.ID NOT IN (SELECT DISTINCT SOR.PROPERTY_ID FROM b_sale_order_props_relation SOR))";
}
}
}