LeadContactTable::unbindAllLeads

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. LeadContactTable
  4. unbindAllLeads
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/binding/leadcontact.php
  • Класс: Bitrix\Crm\Binding\LeadContactTable
  • Вызов: LeadContactTable::unbindAllLeads
static function unbindAllLeads($contactID)
{
	$contactID = (int)$contactID;
	if($contactID <= 0)
	{
		throw new Main\ArgumentException('Must be greater than zero', 'contactID');
	}

	$connection = Main\Application::getConnection();
	$connection->queryExecute(
	/** @lang text */
		"DELETE FROM b_crm_lead_contact WHERE CONTACT_ID = {$contactID}"
	);
	$connection->queryExecute(
	/** @lang text */
		"UPDATE b_crm_lead SET CONTACT_ID =
		(SELECT MIN(CONTACT_ID) FROM b_crm_lead_contact t WHERE t.LEAD_ID = b_crm_lead.ID)
		WHERE CONTACT_ID = {$contactID}"
	);
}

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