• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/stateservice.php
  • Класс: CBPStateService
  • Вызов: CBPStateService::getWorkflowIntegerId
static function getWorkflowIntegerId($workflowId)
{
	global $DB;

	$workflowId = trim($workflowId);
	if ($workflowId == '')
		throw new Exception("workflowId");

	$dbResult = $DB->Query(
		"SELECT ID FROM b_bp_workflow_state_identify WHERE WORKFLOW_ID = '".$DB->ForSql($workflowId)."' "
	);

	$result = $dbResult->fetch();
	if (!$result)
	{
		$strSql =
			"INSERT INTO b_bp_workflow_state_identify (WORKFLOW_ID) ".
			"VALUES ('".$DB->ForSql($workflowId)."')";
		$res = $DB->Query($strSql, true);
		//crutch for #0071996
		if ($res)
		{
			$result = array('ID' => $DB->LastID());
		}
		else
		{
			$dbResult = $DB->Query(
				"SELECT ID FROM b_bp_workflow_state_identify WHERE WORKFLOW_ID = '".$DB->ForSql($workflowId)."' "
			);

			$result = $dbResult->fetch();
		}
	}
	return (int)$result['ID'];
}