%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 18.119.110.38 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/location/lib/model/ |
Upload File : |
<?php namespace Bitrix\Location\Model; use Bitrix\Main, Bitrix\Main\ORM\Fields; use Bitrix\Main\Application; use Bitrix\Main\ORM\Fields\Relations\Reference; use Bitrix\Main\ORM\Query\Join; /** * Class HierarchyTable * * Fields: * <ul> * <li> ANCESTOR_ID int mandatory * <li> DESCENDANT_ID int mandatory * <li> LEVEL int mandatory * </ul> * * @package Bitrix\Location * * DO NOT WRITE ANYTHING BELOW THIS * * <<< ORMENTITYANNOTATION * @method static EO_Hierarchy_Query query() * @method static EO_Hierarchy_Result getByPrimary($primary, array $parameters = array()) * @method static EO_Hierarchy_Result getById($id) * @method static EO_Hierarchy_Result getList(array $parameters = array()) * @method static EO_Hierarchy_Entity getEntity() * @method static \Bitrix\Location\Model\EO_Hierarchy createObject($setDefaultValues = true) * @method static \Bitrix\Location\Model\EO_Hierarchy_Collection createCollection() * @method static \Bitrix\Location\Model\EO_Hierarchy wakeUpObject($row) * @method static \Bitrix\Location\Model\EO_Hierarchy_Collection wakeUpCollection($rows) */ class HierarchyTable extends Main\Entity\DataManager { /** * Returns DB table name for entity. * * @return string */ public static function getTableName() { return 'b_location_hierarchy'; } /** * Returns entity map definition. * * @return array */ public static function getMap() { return array( (new Fields\IntegerField('ANCESTOR_ID')) ->configurePrimary(true), (new Fields\IntegerField('DESCENDANT_ID')) ->configurePrimary(true), (new Fields\IntegerField('LEVEL')) ->configureRequired(true), // References (new Reference('ANCESTOR', LocationTable::class, Join::on('this.ANCESTOR_ID', 'ref.ID'))) ->configureJoinType('inner'), (new Reference('DESCENDANT', LocationTable::class, Join::on('this.DESCENDANT_ID', 'ref.ID'))) ->configureJoinType('inner') ); } /** * @param array $data * @return Main\DB\Result * @throws Main\Db\SqlQueryException */ public static function insertBatch(array $data) { $values = []; foreach ($data as $row) { if((int)$row['ANCESTOR_ID'] <= 0 || (int)$row['DESCENDANT_ID'] <= 0) { continue; } $values[] = (int)$row['ANCESTOR_ID'].', '.(int)$row['DESCENDANT_ID'].', '.(int)$row['LEVEL']; } if(!empty($values)) { $values = '(' . implode('), (', $values) . ')'; $sql = "INSERT IGNORE INTO " . static::getTableName() . " (ANCESTOR_ID, DESCENDANT_ID, LEVEL) VALUES " . $values; Application::getConnection()->queryExecute($sql); } } /** * @param int $locationId * @throws Main\Db\SqlQueryException */ public static function deleteByLocationId(int $locationId) { $locationId = (int)$locationId; Application::getConnection()->queryExecute(" DELETE FROM ".self::getTableName()." WHERE ANCESTOR_ID=".$locationId." OR DESCENDANT_ID = ".$locationId ); } }