Dependence::setPrevious

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Dependence
  4. setPrevious
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/dependence.php
  • Класс: BitrixTasksControlDependence
  • Вызов: Dependence::setPrevious
public function setPrevious($depends = [])
{
	$this->loadTask();

	$this->deleteByTask();

	if (
		!is_array($depends)
		|| empty($depends)
	)
	{
		return;
	}

	$depends = array_map(function($el) {
		return (int) $el;
	}, $depends);
	$depends = array_unique($depends);

	$insertRows = [];
	foreach ($depends as $dependId)
	{
		$insertRows[] = [
			'TASK_ID' => $this->taskId,
			'DEPENDS_ON_ID' => $dependId,
		];
	}

	$insertRows = array_map(function($el) {
		return implode(',', $el);
	}, $insertRows);

	$sql = "
		INSERT INTO ". RelatedTable::getTableName() ."
		(`TASK_ID`, `DEPENDS_ON_ID`)
		VALUES
		(". implode("),(", $insertRows) .")
	";

	Application::getConnection()->query($sql);
}

Добавить комментарий