• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/pgsql/database.php
  • Класс: CDatabase
  • Вызов: CDatabase::Insert
public function Insert($table, $arFields, $error_position="", $DEBUG=false, $EXIST_ID="", $ignore_errors=false)
{
	if (!is_array($arFields))
		return false;

	$str1 = "";
	$str2 = "";
	foreach ($arFields as $field => $value)
	{
		$str1 .= ($str1 <> ""? ", ":"") . $this->quote($field);
		if ((string)$value == '')
			$str2 .= ($str2 <> ""? ", ":"")."''";
		else
			$str2 .= ($str2 <> ""? ", ":"").$value;
	}

	if ($EXIST_ID <> '')
	{
		$strSql = "INSERT INTO ".$table."(ID,".$str1.") VALUES ('".$this->ForSql($EXIST_ID)."',".$str2.") RETURNING ID";
	}
	else
	{
		$strSql = "INSERT INTO ".$table."(".$str1.") VALUES (".$str2.") RETURNING ID";
	}

	if ($DEBUG)
		echo "
".htmlspecialcharsEx($strSql)."
"; $res = $this->Query($strSql, $ignore_errors, $error_position); if ($res === false) return false; $row = $res->Fetch(); return array_shift($row); }