Для работы с базой данных используется специальный класс.
По умолчанию используется функция mysqli в php
В панели администратора (меню Настройки) можно выполнять некоторые текущие работы с базой данных:
Работа с этими функциями интуитивно понятна и проста.
Код | Описание |
---|---|
$db->get_results | get multiple row result set from the database (or previously cached results) |
$db->get_row | get one row from the database (or previously cached results) |
$db->get_col | get one column from query (or previously cached results) based on column offset |
$db->get_var | get one variable, from one row, from the database (or previously cached results) |
$db->query | send a query to the database (and if any results, cache them) |
$db->debug | print last sql query and returned results (if any) |
$db->vardump | print the contents and structure of any variable |
$db->escape | Format a string correctly to stop accidental mal formed queries under all PHP conditions |
Код | Описание |
---|---|
$db->num_rows | Number of rows that were returned (by the database) for the last query (if any) |
$db->insert_id | ID generated from the AUTO_INCRIMENT of the previous INSERT operation (if any) |
$db->rows_affected | Number of rows affected (in the database) by the last INSERT, UPDATE or DELETE (if any) |
$db->tables | массив используемых таблицами |
$db->last_error | последняя ошибка в запросе, если была |
$db->query($query);
if(!empty($db->last_error)){ return db_error(basename(__FILE__).": 226"); }
//Получить массив сайтов:
$sites = $db->get_results("SELECT id, site_url FROM ".$db->tables['site_info']." ORDER BY id ", ARRAY_A);
bitrix (3) шаблон (3) mobile (2) pagespeed (2) simpla (2) блоки (2) переменные (2) cms (1) email (1) google merchant center (1) hosting (1) seo (1) wordpress (1) валюты (1) константы (1) мобильная версия (1) платежи (1) посетители (1) рассылка (1) сравнение (1) теги (1) фильтр (1) шаблоны (1) яндекс маркет (1)