• Модуль: learning
  • Путь к файлу: ~/bitrix/modules/learning/classes/general/clearnhelper.php
  • Класс: CLearnHelper
  • Вызов: CLearnHelper::SQLClauseForAllSubLessons
static function SQLClauseForAllSubLessons ($parentLessonId)
{
	if ( ! (
		is_numeric($parentLessonId)
		&& is_int($parentLessonId + 0)
		)
	)
	{
		throw new LearnException (
			'$parentLessonId must be strictly castable to integer',
			LearnException::EXC_ERR_ALL_PARAMS);
	}

	// MySQL & MSSQL supports "WHERE IN(...)" clause for more than 10 000 elements

	$oTree = CLearnLesson::GetTree($parentLessonId, array('EDGE_SORT' => 'ASC'), array('CHECK_PERMISSIONS' => 'N'));
	$arChildLessonsIds = $oTree->GetLessonsIdListInTree();	// parent lesson id isn't included

	// We need escape data for SQL
	$arChildLessonsIdsEscaped = array_map('intval', $arChildLessonsIds);

	$sqlChildLessonsIdsList = implode (', ', $arChildLessonsIdsEscaped);

	// No childs => nothing must be selected
	if ($sqlChildLessonsIdsList == '')
		$sqlChildLessonsIdsList = 'NULL';		// NULL != any value. NULL != NULL too.

	return ($sqlChildLessonsIdsList);
}