• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/db/blockinserter.php
  • Класс: BitrixSaleLocationDBBlockInserter
  • Вызов: BlockInserter::initIndexFromField
public function initIndexFromField($fld = 'ID')
{
	if($fld == '')
		throw new MainSystemException('Field is not set');

	$fld = $this->dbHelper->forSql($fld);

	$sql = 'select MAX('.$fld.') as VAL from '.$this->tableName;

	$res = $this->dbConnection->query($sql)->fetch();
	$this->index = intval($res['VAL']);

	/*
	$sql = 'select '.$fld.' from '.$this->tableName.' order by '.$fld.' desc';
	$sql = $this->dbHelper->getTopSql($sql, 1);

	$res = $this->dbConnection->query($sql)->fetch();
	$this->index = intval($res[$this->autoIncFld]);
	*/

	return $this->index;
}