QueryBind
This method is for use with the Oracle version only!
mixed CDatabase::QueryBind( string sql, array binds, bool ignore_errors=false, string error_position="" )
The method executes SQL "UPD ATE" or "INS ERT" queries that require variable binding (usually with BLOB, CLOB, LONG fields and etc.). Non-static method
The method returns an CDBResult object class on success.
If an error occurs and the ignore_errors parameter equals "true", the method returns "false".
If an error occurs and the ignore_errors parameter equals "false", the method interrupts page execution, the method interrupts page execution and performs the following operations beforehand:
- Calls the AddMessage2Log method.
- If the current user is a site administrator, the /bitrix/php_interface/dbconn.php file has the initialized $DBDebug=true; variable, the screen will display the full text of the error, otherwise the SendError method will be called.
- The /bitrix/php_interface/dbquery_error.php file will be connected. If it doesn't exist, the file /bitrix/modules/main/include/dbquery_error.php file will be connected instead.
Parameters
Paraemter | Description | |
---|---|---|
sql | SQL query. | |
binds | Array of BLOB, CLOB, LONG fields etc. in the array("field name" => "value" [, ...]) format. | |
ignore_errors | Specifies to ignore errors. If set to "true", the method returns "false" when an error is encountered.
If the ignore_errors parameter equals "false", then in case of an error the function terminates execution of complete page. Optional; "false" by default. | |
error_position | String that identifies position in code fr om where the CDatabase::QueryBind method was called. If an SQL query fails and the file/bitrix/php_interface/dbconn.php has the $DBDebug=true; variable, both error_position and SQL query will be displayed on the screen. Optional. |
See Also
Examples of use
<? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php"); $APPLICATION->SetTitle("TEST CLOB"); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php"); // refresh a field $MY_FIELD_VALUE = "123"; // refresh field MY_FIELD of the type CLOB $strError = ""; $arFields["NEWS_TEXT_FCK"] = $MY_FIELD_VALUE; $strUpdate = $DB->PrepareUpdate("aa_abc", $arFields); if($strUpdate != "") { $strSql = "UPDATE aa_abc SE T ".$strUpdate." WH ERE ID=15"; // variable $MY_FIELD_VALUE contains the text of length more than 4000 symbols $arBinds = array("NEWS_TEXT_FCK" => $MY_FIELD_VALUE); // execute query to bind :MY_FIELD to a real val ue if(!$DB->QueryBind($strSql, $arBinds)) $strError = "Query Error!"; } if($strError=="") echo "all Ok!"; require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php"); ?>
© «Bitrix24», 2001-2024