A
A
Alexander2020-04-28 15:31:22
1C-Bitrix
Alexander, 2020-04-28 15:31:22

How to create tables in the database for your module?

Tell me how to create the necessary tables for it when installing your module. As I understand it, this should be done in the install/index.php file in the InstallDB method, but the syntax of the creation process is not very clear, which Bitrix classes should be accessed.

How to create a description for the fields of a table with all the parameters and is it possible to create a table using only the D7 syntax (since most of the module I have written in it)?

In the table, you need to create the following list of fields:


ID // stores the primary key with autoincrement
ELEMENT_ID
UF_XML_ID
ELEMENT_FIELDS // stores the serialized array of highload block element fields
HL_FIELDS
HLID
HLNAME

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-04-28
@inviziblll

Tables in the database are created the old fashioned way through a SQL query create table. Actually, you can take out the creation of tables from a separate file, for example, install.sql , and call in the installation method:

$sql = file_get_contents(__DIR__ .'/install.sql');
if ($sql) {
    Bitrix\Main\Application::getConnection()->query($sql);
}

How to create a description for the fields of a table with all the parameters and is it possible to create a table using only the D7 syntax (since most of the module I have written in it)?

To do this, you need to create DateManager classes (you don’t need to copy them anywhere during installation, you need to place them in the lib), as you can read in the documentation: https://dev.1c-bitrix.ru/learning/course/index.php.. .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question