Documentation
README
Direct Database Work
Baseline: main 23.0+. ORM is the first choice (bitrix-orm — prefer query() / ConditionTree, and ORM write APIs including batch / merge / deleteByFilter before dropping to SQL). Direct SQL is needed for:
- Migrations/DDL in
install/index.php/updater.php, - Bulk operations (
UPSERT,REPLACE, windows/CTE), - Reports with
GROUP BY/aggregates that are cumbersome to build via ORM, - Working with multiple connections (analytical replica, Redis).
Connection
use Bitrix\Main\Application;
use Bitrix\Main\DB\Connection;
/** @var Connection $db */
$db = Application::getConnection(); // default
$db = Application::getConnection('default');
$analytics = Application::getConnection('analytics'); // additional
This is the opening of the README. Read the full README on GitHub.