1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
discount_convert.php
См. документацию.
1<?php
2
4{
5 public static $strTableName = 'b_catalog_dsc_tmp';
6 public static $strMainTableName = 'b_catalog_discount';
7 public static $boolError = false;
8 public static $arErrors = false;
9
10 public static function CreateTable()
11 {
12 global $DB;
13
14 if (self::$boolError)
15 return false;
16
17 $strSql = "SHOW TABLES LIKE '".$DB->ForSql(self::$strTableName)."'";
18 $dbResult = $DB->Query($strSql);
19 if (!($arResult = $dbResult->Fetch()))
20 {
21 $strSql = "CREATE TABLE ".self::$strTableName." (
22 ID INT NOT NULL,
23 PRIMARY KEY (ID)
24 )";
25 $result = $DB->Query($strSql, true);
26
27 if (!$result)
28 {
29 self::$boolError = true;
30 if (!is_array(self::$arErrors))
31 self::$arErrors = array();
32 self::$arErrors[] = $DB->db_Error;
33 return false;
34 }
35 }
36 return true;
37 }
38
39 public static function DropTable()
40 {
41 global $DB;
42
43 if (self::$boolError)
44 return false;
45
46 $strSql = "DROP TABLE IF EXISTS ".self::$strTableName;
47 $result = $DB->Query($strSql, true);
48
49 if (!$result)
50 {
51 self::$boolError = true;
52 if (!is_array(self::$arErrors))
53 self::$arErrors = array();
54 self::$arErrors[] = $DB->db_Error;
55 return false;
56 }
57 return true;
58 }
59
60 public static function IsExistID($intID)
61 {
62 if (self::$boolError)
63 return false;
64
65 $intID = intval($intID);
66 if (0 >= $intID)
67 return false;
68
69 global $DB;
70
71 $strSql = "SELECT COUNT(ID) as CNT FROM ".self::$strTableName." WHERE ID = ".$intID;
72 $rsCounts = $DB->Query($strSql, true);
73 if ($arCount = $rsCounts->Fetch())
74 {
75 return (0 < intval($arCount['CNT']) ? 1 : 0);
76 }
77 else
78 {
79 return false;
80 }
81 }
82
83 public static function GetLastID()
84 {
85 if (self::$boolError)
86 return false;
87
88 global $DB;
89
90 $strSql = "SELECT ID FROM ".self::$strTableName." WHERE 1 = 1 ORDER BY ID DESC LIMIT 1";
91 $rsLasts = $DB->Query($strSql, true);
92 if ($arLast = $rsLasts->Fetch())
93 {
94 return intval($arLast['ID']);
95 }
96 else
97 {
98 return 0;
99 }
100 }
101
102 public static function SetID($intID)
103 {
104 if (self::$boolError)
105 return false;
106
107 $intID = intval($intID);
108 if (0 >= $intID)
109 return false;
110
111 global $DB;
112
113 $strSql = "INSERT INTO ".self::$strTableName."(ID) VALUES(".$intID.")";
114 $rsRes = $DB->Query($strSql, true);
115 return (!(false === $rsRes));
116 }
117
118 public static function GetNeedConvert($intMinProduct)
119 {
120 if (self::$boolError)
121 return false;
122
123 global $DB;
124
125 $intMinProduct = intval($intMinProduct);
126 if (0 >= $intMinProduct)
127 $intMinProduct = 0;
128
129 $strSql = "SELECT COUNT(CD.ID) as CNT FROM ".self::$strMainTableName." CD WHERE
130 CD.TYPE = ".CCatalogDiscount::ENTITY_ID." AND CD.VERSION = ".CCatalogDiscount::CURRENT_FORMAT."
131 AND CD.ID NOT IN (SELECT CDT.ID FROM ".self::$strTableName." CDT WHERE 1=1)";
132 if (0 < $intMinProduct)
133 {
134 $strSql .= " AND CD.ID > ".$intMinProduct;
135 }
136 $rsCounts = $DB->Query($strSql, true);
137 if ($arCount = $rsCounts->Fetch())
138 {
139 return intval($arCount['CNT']);
140 }
141 else
142 {
143 return false;
144 }
145 }
146}
$arResult
Определения generate_coupon.php:16
const ENTITY_ID
Определения discount.php:22
const CURRENT_FORMAT
Определения discount.php:23
static $strTableName
Определения discount_convert.php:5
static $arErrors
Определения discount_convert.php:8
static CreateTable()
Определения discount_convert.php:10
static $strMainTableName
Определения discount_convert.php:6
static GetLastID()
Определения discount_convert.php:83
static DropTable()
Определения discount_convert.php:39
static GetNeedConvert($intMinProduct)
Определения discount_convert.php:118
static IsExistID($intID)
Определения discount_convert.php:60
static $boolError
Определения discount_convert.php:7
static SetID($intID)
Определения discount_convert.php:102
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
global $DB
Определения cron_frame.php:29
$dbResult
Определения updtr957.php:3