• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/model/call.php
  • Класс: BitrixImModelCallTable
  • Вызов: CallTable::updateState
static function updateState(int $id, string $newState) : bool
{
	$connection = Application::getConnection();
	$sqlHelper = $connection->getSqlHelper();
	$tableName = static::getTableName();
	$newState = $sqlHelper->forSql($newState);

	$update = "STATE = '$newState'";
	if($newState === Call::STATE_FINISHED)
	{
		$update .= ", END_DATE = CURRENT_TIMESTAMP";
	}

	$query = "
		UPDATE
			$tableName
		SET
			$update
		WHERE
			ID = $id
			AND STATE != '$newState'
	";

	$connection->query($query);
	return $connection->getAffectedRowsCount() === 1;
}