本文整理汇总了PHP中Bitrix\Iblock\PropertyTable::query方法的典型用法代码示例。如果您正苦于以下问题:PHP PropertyTable::query方法的具体用法?PHP PropertyTable::query怎么用?PHP PropertyTable::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Iblock\PropertyTable
的用法示例。
在下文中一共展示了PropertyTable::query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: properties
public static function properties($primary)
{
if (!$primary) {
throw new ArgumentException('Не указан идентификатор инфоблока');
}
$cache = new \CPHPCache();
$path = self::createPath(__METHOD__);
$cacheId = md5($primary);
if ($cache->InitCache(86400, $cacheId, $path)) {
$props = $cache->GetVars();
} else {
$field = is_numeric($primary) ? 'IBLOCK_ID' : 'IBLOCK.CODE';
$db = PropertyTable::query()->addFilter($field, $primary)->addSelect('*')->exec();
$props = array();
while ($prop = $db->fetch()) {
$code = $prop['CODE'];
if (isset($props[$code])) {
throw new \LogicException("В инфоблокe {$primary} свойство {$code} используется дважды");
}
if (strlen($code) === 0) {
throw new \LogicException("В инфоблоке {$primary} для свойства {$prop['NAME']} не задан символьный код");
}
$props[$code] = $prop;
}
if ($cache->StartDataCache()) {
$cache->EndDataCache($props);
}
}
return $props;
}
示例2: getItemsIblockShard
/**
* @see IblockFinder::getItems()
*
* @return array
*
* @throws ValueNotFoundException
* @throws ArgumentException
*/
protected function getItemsIblockShard()
{
$items = [];
$rsIblocks = IblockTable::query()->setFilter(['ID' => $this->id])->setSelect(['IBLOCK_TYPE_ID', 'CODE'])->exec();
if ($iblock = $rsIblocks->fetch()) {
if ($iblock['CODE']) {
$items['CODE'] = $iblock['CODE'];
}
$items['TYPE'] = $iblock['IBLOCK_TYPE_ID'];
}
if (empty($items)) {
throw new ValueNotFoundException('Iblock', 'ID #' . $this->id);
}
$propIds = [];
$rsProps = PropertyTable::query()->setFilter(['IBLOCK_ID' => $this->id])->setSelect(['ID', 'CODE', 'IBLOCK_ID'])->exec();
while ($prop = $rsProps->fetch()) {
$propIds[] = $prop['ID'];
$items['PROPS_ID'][$prop['CODE']] = $prop['ID'];
}
if (!empty($propIds)) {
$rsPropsEnum = PropertyEnumerationTable::query()->setFilter(['PROPERTY_ID' => $propIds])->setSelect(['ID', 'XML_ID', 'PROPERTY_ID', 'PROPERTY_CODE' => 'PROPERTY.CODE'])->exec();
while ($propEnum = $rsPropsEnum->fetch()) {
if ($propEnum['PROPERTY_CODE']) {
$items['PROPS_ENUM_ID'][$propEnum['PROPERTY_CODE']][$propEnum['XML_ID']] = $propEnum['ID'];
}
}
}
$this->registerCacheTag('bex_iblock_' . $this->id);
return $items;
}