Answer the question
In order to leave comments, you need to log in
How to connect the $DB global variable to Bitrix in a separate file?
Good evening. I’m not very sure about the elegance of the chosen method for solving the problem, but I’m not very friendly with Bitrix, and I don’t know how to solve my problem using infoblocks. Therefore, I decided to make my own tables in the database and already operate with them.
The point is this. There is a component template, where I create a separate file, example.php, and put all the code that is needed to work with my tables from the database into it. I access this file with Ajax, everything seems to be fine. But the problem is that I want to use $DB->Query to access the database. It seems like you need to make it all available using the global $DB, but it does not connect. How can this problem be solved?
Answer the question
In order to leave comments, you need to log in
Show the code for your file.
Perhaps you have not connected prolog_before - Bitrix service part.
This is done as follows: at the beginning of the script, it is written:
require $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question