• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/model/chatindex.php
  • Класс: BitrixImOpenLinesModelChatIndexTable
  • Вызов: ChatIndexTable::updateIndex
static function updateIndex(int $chatId, ?string $title = null): void
{
	$title ??= static::getChatTitle($chatId);

	$preparedTitle = static::prepareTitle($title);
	if ($preparedTitle === '')
	{
		self::delete($chatId);

		return;
	}

	$helper = Application::getConnection()->getSqlHelper();
	$updateData['SEARCH_TITLE'] = new SqlExpression($helper->getConditionalAssignment('SEARCH_TITLE', $preparedTitle));

	$update = $helper->prepareUpdate(
		static::getTableName(),
		$updateData
	);

	if ($update[0] !== '')
	{
		return;
	}

	$tableName = static::getTableName();
	$primaryField = static::getEntity()->getPrimary();
	Application::getConnection()->query("UPDATE {$tableName} SET {$update[0]} WHERE {$primaryField} = {$chatId}");
}