Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sitelink.php
1<?php
9
10use Bitrix\Main;
14
17
18Loc::loadMessages(__FILE__);
19
36final class SiteLinkTable extends Entity\DataManager
37{
38 public static function getFilePath()
39 {
40 return __FILE__;
41 }
42
43 public static function getTableName()
44 {
45 return 'b_sale_loc_search_sitlnk';
46 }
47
48 public static function checkTableExists()
49 {
50 static $tableExists;
51
52 if($tableExists === null)
53 $tableExists = Main\HttpApplication::getConnection()->isTableExists(static::getTableName());
54
55 return $tableExists;
56 }
57
58 public static function cleanUpData()
59 {
60 Helper::dropTable(static::getTableName());
61
62 // ORACLE: OK, MSSQL: OK
63 $sql = "create table ".static::getTableName()."
64 (
65 LOCATION_ID ".Helper::getSqlForDataType('int').",
66 SITE_ID ".Helper::getSqlForDataType('char', 2).",
67
68 primary key (LOCATION_ID, SITE_ID)
69 )";
70
71 Main\HttpApplication::getConnection()->query($sql);
72 }
73
74 public static function initializeData()
75 {
76 $locationTable = Location\LocationTable::getTableName();
77 $groupLocationTable = Location\GroupLocationTable::getTableName();
78 $siteLocationTable = Location\SiteLocationTable::getTableName();
79
80 // ORACLE: OK, MSSQL: OK
81 $sql = "
82 insert into ".static::getTableName()."
83 (LOCATION_ID, SITE_ID)
84 select LC.ID, LS.SITE_ID
85 from ".$siteLocationTable." LS
86 inner join ".$locationTable." L on LS.LOCATION_ID = L.ID and LS.LOCATION_TYPE = 'L'
87 inner join ".$locationTable." LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN
88 union
89 select LC.ID, LS.SITE_ID
90 from ".$siteLocationTable." LS
91 inner join ".$groupLocationTable." LG on LS.LOCATION_ID = LG.LOCATION_GROUP_ID and LS.LOCATION_TYPE = 'G'
92 inner join ".$locationTable." L on LG.LOCATION_ID = L.ID
93 inner join ".$locationTable." LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN
94 ";
95
96 Main\HttpApplication::getConnection()->query($sql);
97 }
98
99 public static function createIndex()
100 {
101 Helper::createIndex(static::getTableName(), 'S', array('SITE_ID'));
102 }
103
104 public static function getMap()
105 {
106 return array(
107
108 'LOCATION_ID' => array(
109 'data_type' => 'integer',
110 'required' => true,
111 'primary' => true
112 ),
113 'SITE_ID' => array(
114 'data_type' => 'integer',
115 'required' => true,
116 'primary' => true
117 ),
118 );
119 }
120}
121
static loadMessages($file)
Definition loc.php:64