array CDatabase::PrepareUpdate( string table, array fields, string dir="", string site=false )
The method PrepareUpdate prepares an string for issuing an SQL query used to update a record in the database. The method converts all values to the SQL-compliant format with respect to the field type and handles file operations returning the ID from the file table.
Parameter | Description |
---|---|
table | Name of the table. |
fields | Array of field values in the form of "field name1"=>"value1", "field name2"=>"value2" [, ...].
Use a value of false to insert NULL. To insert a file attached to a record, set a value to an array of the following format: Array( "name" => "file name", "size" => "file size", "tmp_name" => "temporary path and name on the server", "type" => "file type", "del" => "delete (Y) or not (N) the file", "MODULE_ID" => "module name");You can easily build such an array by combining arrays $HTTP_POST_FILES[field name] and Array("del" => ${"field_name"."_del"}, "MODULE_ID" = "module name"); Any table field that does not have corresponding entry in the array will remain unchanged. |
dir | Name of the folder to store files (the folder is created in the folder upload). Used for the inserting files attached to a record.
Optional; the default value is an empty string. |
site | Site ID (for public section) or the language ID (for administrative section). Used to determine the date format when inserting fields of the type date or datetime .Optional; the current ID is used by default. |
Returns the string of the format "field name1=value1, field name2= value2[, ...]".
<? function UpdateResultField($arFields, $RESULT_ID, $FIELD_ID) { $err_mess = (CForm::err_mess())."<br>Function: UpdateResultField<br>Line: "; global $DB; $RESULT_ID = intval($RESULT_ID); $FIELD_ID = intval($FIELD_ID); $strUpdate = $DB->PrepareUpdate("b_form_result_answer", $arFields, "form"); $strSql = "UPDATE b_form_result_answer SET ".$strUpdate." WHERE RESULT_ID=".$RESULT_ID." and FIELD_ID=".$FIELD_ID; $DB->Query($strSql, false, $err_mess.__LINE__); } ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |