// Parse settings.data into separate variable
let settings_data = JSON.parse(settings.data);
// Update settings_data object by new value
settings_data.methodProperties.CityName="дол";
// Update settings.data by new stringified value
settings.data = JSON.stringify(settings_data);
// Test
alert(JSON.parse(settings.data).methodProperties.CityName);
<?php
$str = "Яблоко, Апельсин, <br>Киви, <u>Молоко</u>, <a src='//'>ссылка</a>";
echo strip_tags($str);
В случае PostgreSQL: bitmap index обеспечивают значительное и преимущество в производительности для данных с низким количеством вариантов при приемущественном чтении.
<?php
function checkNum($num){
$commission1 = 5;
$commission2 = 7;
return (($num - $num*$commission1/100 - $num*$commission2/100) % 10) == 0;
}
function getMaxValidSum($sum){
for ($i=$sum; $i>0; $i--){
if (checkNum($i)) {
return $i;
}
}
print("Недостаточно средств для списания.");
}
print(getMaxValidSum(983));
Не благодарите :)
<?php
for ($m = 0; $m <= 59; $m++) {
echo "<option>" . str_pad($m, 2, '0', STR_PAD_LEFT) . "</option>";
echo PHP_EOL;
}
select
groups.id_group,
groups.name_group,
count(distinct users.id_user) size_group
from groups
join users on users.id_group = groups.id_group
group by groups.id_group, groups.name_group
having count(distinct users.id_user) between 1 and 5
;
SELECT
to_timestamp(('1591044532022001'::bigint)/1000000) ts1,
to_timestamp((regexp_replace('1 591 044 464 658 000,00', '[\s,]','','g')::bigint)/100000000) ts2
SELECT *
FROM `tab1`
JOIN `tab2`
ON LOWER(`tab1`.`name`) LIKE CONCAT('%', LOWER(`tab2`.`name`), '%');
select * from test
join (
select "hash" from test where "on" order by random() limit 1
) t on t.hash = test.hash;
select
class,
price
from (
select
class,
price,
row_number() over (partition by class order by price) rn
from complex
) prices
where
(class=1 and rn < 3) -- 2 econom
or (class=2 and rn < 4) -- 3 comfort
or (class=3 and rn < 2) -- 1 premium
;
SELECT * FROM `advert` WHERE `active` = '1' AND `type` = '1' ORDER BY `price`;
<?php
function reverse_vowels($word)
{
// получаем строку всех гласных букв. в слове
$vowels = implode( // объединяем массив в строку
array_filter(// получаем массив всех гласных букв. в слове
str_split($word), // разбиваем слово на буквы
function ($c) { // проверяем если буква гласная [ayeiou]
return preg_match("/[ayeiou]/i", $c);
}
)
);
echo "" . $vowels . PHP_EOL;
$v = 0;
$reverse = implode(// объединяем массив в строку
array_map(
function ($i) use ($word, $vowels, &$v) {// &$v переменная переданная по ссылке
$is_vowel = preg_match("/[ayeiou]/", $word[$i]);
return $is_vowel ? $vowels[strlen($vowels) - 1 - $v++] : $word[$i];
},
range(0, strlen($word) - 1) // массив [0, количество букв в слове - 1]
)
);
return $reverse;
}
echo reverse_vowels('environment');
SELECT
jobs.job_title,
AVG(employees.salary) average_salary
FROM
employees
JOIN jobs ON employees.job_id = jobs.job_id
WHERE
jobs.job_title Like '%Manager'
GROUP BY jobs.job_title
HAVING AVG(employees.salary) > 10000;
SELECT
ID,
tel_balance1 * (tel1 LIKE "38090%") +
tel_balance2 * (tel2 LIKE "38090%") +
tel_balance3 * (tel3 LIKE "38090%") AS balance_38090
FROM
telephone
WHERE
tel1 LIKE "38090%"
OR tel2 LIKE "38090%"
OR tel3 LIKE "38090%"
;
SELECT
COALESCE(departments.department_name, 'Total') AS department_name,
COUNT(*) as Count_employees
FROM
employees
JOIN departments ON employees.department_id = departments.department_id
GROUP BY
ROLLUP(departments.department_name)
ORDER BY departments.department_name;
create table test (
col varchar(64)
);
insert into test
values
('ЧС.1.1'),
('ЧС.1.2'),
('ЧС.1.3.1'),
('ЧС.1.10'),
('ЧС.1.11.1'),
('П.1.1'),
('П.1.2'),
('П.10.2'),
('П.2.10');
select
col
from
test
order by
(string_to_array(col, '.'))[1],
(string_to_array(col, '.'))[2]::int,
(string_to_array(col, '.'))[3]::int;
select col from (
select
col, string_to_array(col, '.') arr
from
test
) tbl
order by
arr[1],
arr[2]::int,
arr[3]::int;