Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/catalog/general/ |
Upload File : |
<?php use Bitrix\Catalog; class CCatalogResult extends CDBResult { /** @var null|Catalog\Model\Entity $entity */ private $entity = null; private $fields = array(); private $resultKeys = array(); private $erasedKeys = array(); public function __construct($entity, $result = null) { parent::__construct($result); $this->entity = new $entity; $this->resultKeys = array(); $this->fields = $this->entity->getCachedFieldList(); if (!empty($this->fields)) $this->resultKeys = array_fill_keys($this->fields, true); } public function setResult($result) { parent::__construct($result); } public function prepareSelect(array $select) { $this->erasedKeys = array(); if ( empty($select) || (is_string($select) && $select == '*') || (is_array($select) && in_array('*', $select)) ) return $select; foreach ($this->fields as $field) { $index = array_search($field, $select); if ($index !== false) continue; $select[] = $field; $this->erasedKeys[$field] = true; } unset($index, $field); return $select; } public function Fetch() { $row = parent::Fetch(); if (!isset($this) || !is_object($this)) return $row; if (empty($row)) { $this->erasedKeys = array(); return $row; } if (empty($this->fields)) return $row; if (isset($row['ID'])) { $this->entity->setCacheItem($row['ID'], $row); if (!empty($this->erasedKeys)) $row = array_diff_key($row, $this->erasedKeys); } return $row; } }