sort($arr['2021.06.25']['type']);
print_r($arr);
Array
(
[2021.06.25] => Array
(
[type] => Array
(
[0] => 06:00:00
[1] => 13:20:00
[2] => 20:45:00
)
)
)
foreach($arClinics as $id => $Clinic) {
$arClinics[$id] = array_filter(
$Clinic,
function($key) {
return $key == 'ID' || $key == 'PROPERTY_SPECIALIZATIONS_VALUE';
},
ARRAY_FILTER_USE_KEY
);
}
$check_alaliable_amount = 'select * from users where id = ?';
$stmt = $mysqli->prepare($check_alaliable_amount);
$stmt->bind_param("i", $client);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
print_r($user);
if ($user['amount'] >= $summa) {
/* Start transaction */
$mysqli->begin_transaction();
try {
$stmt = $mysqli->prepare("update users set amount=(amount-?) where id=?;");
$stmt->bind_param('ii', $summa, $client);
$stmt->execute();
$stmt = $mysqli->prepare("update users set amount=(amount+?) where id=?;");
$stmt->bind_param('ii', $summa, $shop);
$stmt->execute();
$mysqli->commit();
} catch (mysqli_sql_exception $exception) {
$mysqli->rollback();
throw $exception;
}
}
select name, s_name, email
from users
where users.id = 1 and exists (
select 1 from orders where user_id = users.id and product_id = 2
);
select distinct name, s_name, email
from users
join orders on orders.user_id = users.id
where users.id = 1 and product_id = 2;
select *
from cars
where not exists (
select 1
from rental
where
rental.car = cars.regnum
and CURRENT_DATE() between start_date and end_date
);
select *
from cars
where exists (
select 1
from rental
where
rental.car = cars.regnum
and CURRENT_DATE() between start_date and end_date
);
select *
from cars
where exists (
select 1
from rental
where
rental.car = cars.regnum
and start_date > CURRENT_DATE()
);
create table t (
a int
);
insert into t values (2000000000),(2000000000),(2000000000),(2000000000);
select sum(a) * 99 from t;
+==============+
| sum(a) * 99 |
+==============+
| 792000000000 |
+--------------+
<?php
function myDataFormat($d) {
$months = [
'январь'=>'01',
'июнь'=>'06',
'июля'=>'07'
];
$splitted_data = explode(' ', $d);
return $splitted_data[2]
. $months[$splitted_data[1]]
. str_pad($splitted_data[0], 2, '0', STR_PAD_LEFT) ;
}
function mySort($arr) {
usort(
$arr,
function($a, $b) {
return myDataFormat($a['data']) <=> myDataFormat($b['data']);
}
);
return $arr;
}
$arr= [
[
"header"=>'',
"title"=>'',
"data"=>'12 июнь 2021',
],
[
"header"=>'',
"title"=>'',
"data"=>'30 июнь 2021',
],
[
"header"=>'',
"title"=>'',
"data"=>'1 июля 2021',
],
[
"header"=>'',
"title"=>'',
"data"=>'1 январь 2020',
]
];
$sorted = mySort($arr);
print_r($sorted);
select * from test where created_at like '%-01 00:00:00';
update master_products
join (
select master_product_id, MIN(product_prices.price) min_price
from product_prices
join products on product_prices.product_id = products.id
products.published=1 and products.available = 1
group by master_product_id
) min_prices
set price_min = min_prices.min_price
where published = 1 and available = 1;
$title = 'Носки мужские за 490 руб';
$title = preg_replace('/ за ([0-9]+) руб/i', '', $title);
echo $title;