Indexes other than the clustered index are known as secondary indexes. In InnoDB, each record in a secondary index contains the primary key columns for the row, as well as the columns specified for the secondary index. InnoDB uses this primary key value to search for the row in the clustered index.
If the primary key is long, the secondary indexes use more space, so it is advantageous to have a short primary key.
// Ждем когда элементы на странице прогрузятся:
document.addEventListener('DOMContentLoaded', function() {
// Вешаем на кпопку обработчик клика, чтобы при каждом клике
// сразу запускалась функц я dataSend отвечающая за отправку данных:
document.querySelector('.button').addEventListener('click', dataSend);
});
// Функция для отправки данных на сервер:
async function dataSend() {
// Получаем данные с нужных нам полей в переменные:
var loginValue = document.querySelector('.login').value
var emailValue = document.querySelector('.email').value
var passwordValue = document.querySelector('.password').value
var conf_passwordValue = document.querySelector('.conf_password').value
// Создаем объект с данными:
var data = {
'login': loginValue,
'email': emailValue,
'password': passwordValue,
'conf_password': conf_passwordValue
}
// Конвертируем объект в JSON:
var json = JSON.stringify(data);
// Отправялеям полученный JSON на сервер обычным POST-запросом:
var response = await (await fetch('https://yousite.ru/handler.php', {
'method': 'POST',
'headers': {
'Content-Type': 'application/json; charset=utf-8'
},
'body': json
})).text();
// Выводим ответ сервера в консоли:
console.log('Ответ сервера:');
console.log(response);
}
<?php
// Включим показ ошибок:
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
// Считываем полученный JSON:
$json = file_get_contents('php://input');
// Раскодируем JSON в массив:
$array = json_decode($json, true);
// Выведем массив, чтобы посмотиеть, что в нем:
header('Content-Type: text/plain; charset=UTF-8'); // Указыавем браузеру, что ответ будет обычным текстом
echo "Из браузера получены следующие данные:\n"; // Выведем текст-предупреждение
print_r($array); // Выведем все, что находится в массиве
foreach ($arBlocks as $IBLOCK_ID) {
$multiplier = getPriceMultiplierByBlock($IBLOCK_ID);
$newPrice = $price * $multiplier;
// сохраняйте
}
function getPriceMultiplierByBlock($blockId) {
$multipliers = [
2 => 1.30,
8 => 1.30,
9 => 1.20,
43 => 1.25,
44 => 1.20,
45 => 1.10,
99 => 1.10,
// ...
];
return isset($multipliers[$blockId])
? $multipliers[$blockId]
: 1; // если множитель не указан - единица
}