Bitrix Site Manager

CDatabase

The CDatabase class is used to work with the database.

When a page is created, an object $DB of the class CDatabase is automatically created. You must use this object to perform any operation on the database.

Methods

Method Description
ForSql Prepares the string for insertion into an SQL query.
Query Performs a query to the database and returns the query result.
QueryBind Executes SQL queries like "UPDATE" or "INSERT" that require variable binding.
QueryBindSelect Executes a "SELECT" SQL query that require variable binding.
Update Updates records in the table with the values passed.
NextID Returns the next value from the sequence.
Insert Inserts a record with fields to the table.
LastID Returns the ID of the last added record.
PrepareFields Prepares global variables for insertion in an SQL query.
PrepareInsert Prepares an array of the two strings for issuing an SQL query used to insert a record in the database.
PrepareUpdate Prepares an string for issuing an SQL query used to update a record in the database.
InitTableVarsForEdit Creates global variables used for the display.
ParseSqlBatch Parses the string containing a bundle of queries.
RunSqlBatch Executes a set of queries contained in the file.
StartTransaction Open a transaction.
Commit Commits the commenced transaction.
Rollback Rolls back all changes made by the incomplete open transaction.
Connect Opens a connection to the database.
Disconnect Closes the previously opened connection to the database.

Date and time handling methods

Method Description
CurrentDateFunction Used to obtain the SQL function returning the current date.
CurrentTimeFunction Returns the function used to obtain the current time.
CharToDateFunction Returns a string used to insert the date in the database query.
DateToCharFunction Returns a string used to obtain the date in the database query.
DateFormatToPHP Converts any date and time format allowed by the site settings to the PHP format.
FormatDate Converts the date from the source format into another.
CompareDates Compares two dates.
IsDate Checks the date for validity.

See Also