- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/database.php
- Класс: CAllDatabase
- Вызов: CAllDatabase::Update
public function Update($table, $arFields, $WHERE="", $error_position="", $DEBUG=false, $ignore_errors=false, $additional_check=true)
{
$rows = 0;
if(is_array($arFields))
{
$ar = array();
foreach($arFields as $field => $value)
{
if ((string)$value == '')
$ar[] = $this->quote($field) . " = ''";
else
$ar[] = $this->quote($field) . " = ".$value."";
}
if (!empty($ar))
{
$strSql = "UPDATE ".$table." SET ".implode(", ", $ar)." ".$WHERE;
if ($DEBUG)
echo "
".htmlspecialcharsEx($strSql)."
";
$w = $this->Query($strSql, $ignore_errors, $error_position);
if (is_object($w))
{
$rows = $w->AffectedRowsCount();
if ($DEBUG)
echo "affected_rows = ".$rows."
";
if ($rows <= 0 && $additional_check)
{
$w = $this->Query("SELECT 'x' FROM ".$table." ".$WHERE, $ignore_errors, $error_position);
if (is_object($w))
{
if ($w->Fetch())
$rows = $w->SelectedRowsCount();
if ($DEBUG)
echo "num_rows = ".$rows."
";
}
}
}
}
}
return $rows;
}