• Модуль: learning
  • Путь к файлу: ~/bitrix/modules/learning/classes/general/ilearngraphrelation.php
  • Класс: CLearnGraphRelation
  • Вызов: CLearnGraphRelation::Link
static function Link ($parentNodeId, $childNodeId, $arProperties)
{
	global $DB;

	// reset static cache
	self::$arNodesCache = array();
	self::$nodesCached = 0;

	$args_check = is_array($arProperties) 	// must be an array
		&& (count($arProperties) === 1)
		&& ($parentNodeId > 0)
		&& ($childNodeId > 0);

	// Only SORT allowed
	$args_check = $args_check && isset ($arProperties['SORT']);

	// check SORT admitted range: number
	if (isset($arProperties['SORT']))
		$args_check = $args_check && is_numeric ($arProperties['SORT']) && is_int ($arProperties['SORT'] + 0);
	else
		$args_check = false;

	if ( ! $args_check )
	{
		throw new LearnException (
			'EA_PARAMS: ' . $parentNodeId . ' / ' . $childNodeId . ' / ' . var_export($arProperties, true), 
			LearnException::EXC_ERR_GR_LINK);
	}

	// normalize & sanitize
	{
		$sort = (int) ($arProperties['SORT'] + 0);

		$parentNodeId += 0;
		$childNodeId  += 0;
	}

	// Create graph edge
	$rc = $DB->Query (
		"INSERT INTO b_learn_lesson_edges (SOURCE_NODE, TARGET_NODE, SORT)
		VALUES ('" . $parentNodeId . "', '" . $childNodeId . "', '" . $sort . "')",
		$ignore_errors = true);

	if ($rc === false)
		throw new LearnException ('EA_SQLERROR', LearnException::EXC_ERR_GR_LINK);
}