• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/comparator/tmptable.php
  • Класс: BitrixSaleLocationComparatorTmpTable
  • Вызов: TmpTable::saveData
public function saveData(array $data)
{
	if(empty($data))
		return 0;

	set_time_limit(0);

	$sqlHelper = $this->connection->getSqlHelper();
	$queryBegin = '';

	foreach(current($data) as $key => $val)
	{
		if($queryBegin <> '')
			$queryBegin .= ', ';

		$queryBegin .= $sqlHelper->forSql($key);
	}

	$queryBegin .= ', XML_ID';
	$queryBegin = "INSERT INTO ".$this->name."(".$queryBegin.") VALUES ";
	$imported = 0;
	$i = 0;
	$values = '';
	$INSERT_BLOCK_SIZE = 100;

	foreach($data as $xmlId => $row)
	{
		if($values <> '')
			$values .= ', ';

		$rowValues = '';

		foreach($row as $col)
		{
			if($rowValues <> '')
				$rowValues .= ', ';

			$rowValues .= "'".$sqlHelper->forSql($col)."'";
		}

		$values .= "(".$rowValues.", '".$sqlHelper->forSql($xmlId)."')";

		if($i >= $INSERT_BLOCK_SIZE)
		{
			$this->connection->queryExecute($queryBegin.$values);
			$i = 0;
			$values = '';
		}

		$i++;
		$imported++;
	}

	if($values <> '')
		$this->connection->queryExecute($queryBegin.$values);

	$this->connection->queryExecute("CREATE INDEX IX_BSDTMP_XML_ID ON ".$this->name." (XML_ID)");
	return $imported;
}