UPDATE table
SET column2 = (CASE column1 WHEN 1 THEN 'val1'
WHEN 2 THEN 'val2'
WHEN 3 THEN 'val3'
END)
WHERE column1 IN(1, 2 ,3);
INSERT into `table` (id, fruit)
VALUES (1, 'apple'), (2, 'orange'), (3, 'peach')
ON DUPLICATE KEY UPDATE fruit = VALUES(fruit);
<svg class="youtube-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
<path d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z"></path>
</svg>
/* SVG inline код. Смена цвета по ховеру */
.youtube-icon {
width: 64px;
height: 64px;
fill: black;
}
.youtube-icon:hover {
fill: red;
}
SELECT
@ids := (
SELECT
GROUP_CONCAT(DISTINCT id SEPARATOR ',')
FROM
(
SELECT
id
FROM
test
WHERE
date >= '2022-12-10 08:00:00'
AND date <= '2022-12-10 20:00:00'
ORDER BY
date DESC
LIMIT
2
) AS sub
);
SELECT @ids;
SELECT
SUM(bunker_sum)
FROM
test
WHERE
find_in_set(id, @ids);
#!/bin/bash
a='text / 2022 / 2021 / text / 2019 / ( 2018)'
a=${a//\/} # удаление /
a=${a// /_} # замена пробелов на _
json_encode
). Но в Python-версии вы просто преобразуете словарь в строку (str(data).encode()
), в результате чего получаете не JSON, а строковое представление (representation) словаря. Вам следует использовать модуль json для кодирования словаря в JSON:import hashlib
import hmac
import json
secret_key = "6cc765db400218ab83394f4f3c8e00866b05a0vq"
data = {
'orderId': '6555214',
'shopId': '4d499d82-2b99-4a7e-be26-5742c41e69e7'
}
signature = hmac.new(secret_key.encode(), json.dumps(data).encode(), hashlib.sha256).hexdigest()
data['signature'] = signature
json.encode
нужно указать, какие использовать разделители (без пробелов):signature = hmac.new(secret_key.encode(), json.dumps(data, separators=(',', ':')).encode(), hashlib.sha256).hexdigest()
public function items(): BelongsToMany
{
return $this->belongsToMany(CartProduct::class, 'cart_products');
}
public function items(): BelongsToMany
{
return $this->belongsToMany(ProductVariant::class, 'cart_products');
}
<?php
$date = date('Y-m-01');
$next_month = date('Y-m-d', strtotime('+1 month', strtotime($date)));
function nextWorkDay($date) {
$day_of_week = date('N', strtotime($date));
if ($day_of_week>5) {
//echo "Weekend: " . $date;
$shift = 8-$day_of_week;
return date('Y-m-d', strtotime("+{$shift} day", strtotime($date)));
} else {
echo "Work day ($day_of_week):" . $date . PHP_EOL;
return date('Y-m-d', strtotime('+3 day', strtotime($date)));
}
}
while ($date < $next_month) {
$date = nextWorkDay($date);
}
$tmp = $options['ssl_key'];
$ssl_key = $tmp[0];
$builder = Element::query();
$loadType = 0;
if ($typeId) {
$builder->where('type_id', $typeId);
$loadType |= 1;
}
if($search) {
$builder->where('title', 'like', "%$search%");
$loadType |= 2;
}
$element = $builder->get();
$response->setMessage("Данные успешно загрузил $loadType");
$response->setStatus('OK');
$response->setData(['Element' => $element->load('elementtype')]);
return $response->asJson();