File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/modules/main/lib/service/geoip/internal/geonametable.php
Back
<?php /** * Bitrix Framework * @package bitrix * @subpackage main * @copyright 2001-2022 Bitrix */ namespace Bitrix\Main\Service\GeoIp\Internal; use Bitrix\Main\ORM\Data; use Bitrix\Main\ORM\Fields; use Bitrix\Main\Text\UtfConverter; /** * Class GeonameTable * * DO NOT WRITE ANYTHING BELOW THIS * * <<< ORMENTITYANNOTATION * @method static EO_Geoname_Query query() * @method static EO_Geoname_Result getByPrimary($primary, array $parameters = []) * @method static EO_Geoname_Result getById($id) * @method static EO_Geoname_Result getList(array $parameters = []) * @method static EO_Geoname_Entity getEntity() * @method static \Bitrix\Main\Service\GeoIp\Internal\EO_Geoname createObject($setDefaultValues = true) * @method static \Bitrix\Main\Service\GeoIp\Internal\EO_Geoname_Collection createCollection() * @method static \Bitrix\Main\Service\GeoIp\Internal\EO_Geoname wakeUpObject($row) * @method static \Bitrix\Main\Service\GeoIp\Internal\EO_Geoname_Collection wakeUpCollection($rows) */ class GeonameTable extends Data\DataManager { use Data\Internal\MergeTrait; public static function getTableName() { return 'b_geoname'; } public static function getMap() { return [ (new Fields\IntegerField('ID')) ->configurePrimary(), (new Fields\StringField('LANGUAGE_CODE')) ->configurePrimary(), (new Fields\StringField('NAME')), ]; } public static function save(array $data): void { $existing = static::get(array_keys($data), false); foreach ($data as $geoid => $names) { if (is_array($names)) { foreach ($names as $lang => $name) { if (!isset($existing[$geoid][$lang]) || $existing[$geoid][$lang] != $name) { $insert = [ 'ID' => $geoid, 'LANGUAGE_CODE' => $lang, 'NAME' => $name, ]; $update = [ 'NAME' => $name, ]; static::merge($insert, $update); } } } } } public static function get(array $ids, bool $decode = true): array { $existing = []; if (!empty($ids)) { $query = static::query() ->setSelect(['*']) ->whereIn('ID', $ids) ->exec() ; $converter = ($decode? new UtfConverter(): null); while ($record = $query->fetch($converter)) { $existing[$record['ID']][$record['LANGUAGE_CODE']] = $record['NAME']; } } return $existing; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings