Bitrix Site Manager


 string sql,
 array binds,
 bool ignore_errors=false,
 string error_position="" 

The method QueryBind executes SQL queries like "UPDATE" or "INSERT" that require variable binding (usually with fields BLOB, CLOB, LONG etc.).

This method is for use with the Oracle version only!


sql SQL query.
binds Array of fields BLOB, CLOB, LONG etc. in the format array("field name" => "value" [, ...]).
ignore_errors Specifies to ignore errors. If set to true, the method returns false on failure. If set to false, the method breaks the page execution.
Optional; false by default.
error_position String indicating the method call position in the code (e.g. __LINE__). If an SQL query fails and the file /bitrix/php_interface/dbconn.php has the variable $DBDebug=true;, the error_position and the failure SQL query are printed.

Return Values

The method returns an instance of CDBResult on success.

If an error occurs and the ignore_errors parameter is true, the function returns false. If the ignore_errors parameter is false, the method breaks the page execution, having the following operations performed beforehand.

  1. Calls the function AddMessage2Log.
  2. If the current user is an administrator or the file /bitrix/php_interface/dbconn.php has the variable $DBDebug=true; the full error description is printed. Otherwise, the function SendError is called.
  3. The file /bitrix/php_interface/dbquery_error.php is included. If this file does not exist, the file /bitrix/modules/main/include/dbquery_error.php is included instead.

See Also


// refresh a field

// refresh field MY_FIELD of the type CLOB
$strSql = "UPDATE my_table SET MY_FIELD = :MY_FIELD WHERE ID=1";

// variable $MY_FIELD_VALUE contains 
// the text of length more than 4000 symbols
$arBinds = array("MY_FIELD" => $MY_FIELD_VALUE);

// execute query binding :MY_FIELD to a real value
$DB->QueryBind($strSql, $arBinds);
// insert a new record

$arFields = array(
   // huge field of more than 4000 symbols in length
  "EMAIL" => $EMAIL // short field

// prepare array
$arInsert = $DB->PrepareInsert("my_table", 

// get the ID of a new record
$id = $DB->NextID("sq_my_table");

// prepare an SQL query having ":USER_TEXT" 
// in place of the field USER_TEXT
// that is to be processed by QueryBind
$strSql="INSERT INTO my_table (ID,".$arInsert[0].
        ") VALUES ($id,".$arInsert[1].")";

// prepare the binding array
$arBinds = array("USER_TEXT" => $arFields["USER_TEXT"]);

// insert a new field while 
// binding :USER_TEXT to a real value
$DB->QueryBind($strSql, $arBinds);