• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/propertyindex/dictionary.php
  • Класс: BitrixIblockPropertyIndexDictionary
  • Вызов: Dictionary::getStringId
public function getStringId($value, $addWhenNotFound = true)
{
	if (!isset($this->cache[$value]))
	{
		$connection = BitrixMainApplication::getConnection();

		$sqlHelper  = $connection->getSqlHelper();
		$valueId    = $connection->queryScalar("SELECT ID FROM ".$this->getTableName()." WHERE VALUE = '".$sqlHelper->forSql($value)."'");
		if ($valueId === null)
		{
			if ($addWhenNotFound)
			{
				$valueId = $connection->add($this->getTableName(), array(
					"VALUE" => $value,
				));
			}
			else
			{
				$valueId = 0;
			}
		}

		$this->cache[$value] = intval($valueId);
	}

	return $this->cache[$value];
}