Argument #2 ($array) must be of type ?array, string given in
Аргумент #2 ($array) должен иметь тип ?array, строка указана в
echo implode(',', array_column($arr['domains'], 'fqdn'));
<?php
$html =" <span>
123 </span>";
echo json_encode(["content"=>$html]);
$html =" <span>
123 </span>";
echo '{"content":'.json_encode ($html) .'}';
usort($arr, fn($a, $b)=>$b['STATUS_WORK_DAY']<=>$a['STATUS_WORK_DAY']);
SELECT count(*) from `runs` where `date` >= unix_timestamp(curdate());
SELECT count(distinct client) from `runs` where `date` >= unix_timestamp(curdate());
SELECT COUNT(*) FROM (
SELECT
`client`, MIN(`date`) `first_run`
FROM `runs`
GROUP BY `client`
HAVING `first_run` >= unix_timestamp(curdate())
) `todays_first_runs`;
select t1.customer_id
from t t1
join t t2 on t1.customer_id = t2.customer_id and t2.type_system ='CRM'
where t1.type_system ='DBO'
select *, row_number() over(partition by platform_id order by id) n
from t
order by n, platform_id, id
<?php
function getTags($strTag) {
return array_combine(
array_map(
fn($attribute) => array_shift(explode("=", $attribute)),
explode(" ", trim($strTag))
),
explode(" ", trim($strTag))
);
}
function getAttributes($strTag) {
return array_map(
fn($attribute) => array_pop(explode("=", $attribute)),
getTags($strTag)
);
}
preg_match_all('/(?<=\<img).*?(?=>)/', $this->html, $match, PREG_PATTERN_ORDER);
$this->tags = array_map(
fn($strTag) => [
"original" => "<img " . $strTag . ">",
"attributes" => getAttributes($strTag)
],
$match[0]
);
CREATE SEQUENCE profiles_seq START 1;
CREATE OR REPLACE FUNCTION nextval_rand(regclass)
RETURNS text AS
$func$
BEGIN
EXECUTE format('ALTER SEQUENCE profiles_seq INCREMENT %s', (random() * 100)::int + 1);
RETURN 'Пользователь #' || nextval($1)::text;
END
$func$ LANGUAGE plpgsql SECURITY DEFINER;
create table profiles (
id uuid not null,
username text default nextval_rand('profiles_seq'::regclass),
primary key (id)
);
insert into profiles (id) values
(gen_random_uuid()),
(gen_random_uuid()),
(gen_random_uuid()),
(gen_random_uuid()),
(gen_random_uuid());
select * from profiles;
SELECT [Case].[ID]
FROM [Case]
JOIN [Instance] ON [Instance].[CaseID] = [Case].[ID]
GROUP BY [Case].[ID]
HAVING MAX([Level]) = 1;
SELECT id
FROM tbl
GROUP BY id
HAVING MIN(discount) = 'PROMO' AND MAX(discount) = 'PROMO'
select `order`, item, count(discount)
from store
group by `order`, item
having count(discount) = count(case when discount='PROMO' then 1 end)
select ch1.chat_id
from chat_user ch1
join chat_user ch2 using (chat_id)
where ch1.user_id = 1 and ch2.user_id = 2;
<?php
$input = 'value.id.price.data.get.value';
$result = [];
$r = &$result;
foreach(explode('.', $input) as $k) {
$r[$k] = [];
$r = &$r[$k];
}
print_r($result);
select *
from a,
lateral (select * from b where b.a_id = a.id order by d desc limit 1) m;
select user_id
from t
where value_id = 22
group by user_id
having count(*) = 1
intersect
select user_id
from t
where value_id = 23
group by user_id
having count(*) = 2
with count_values as (
select user_id, value_id, count(*) cnt
from t
group by user_id, value_id
)
select user_id from count_values where value_id = 22 and cnt > 0
intersect
select user_id from count_values where value_id = 23 and cnt > 1
select distinct manufacturer
from spent s
join products p on p.id = s.product_id;
select
products.*,
case when bad_manufacturers.manufacturer is null then 'Хороший производитель' else 'Бракодел' end manufacturer_rate
from products
left join (
select distinct manufacturer
from spent s
join products p on p.id = s.product_id
) bad_manufacturers using (manufacturer)
select
problems.*,
case when coalesce(max(status_id), 2) = 2 then 'Not Completed' else 'Completed' end problem_status
from problems
left join tasks on tasks.problem_id = problems.id
group by problems.id, problems.title
order by problems.id;
with problem_status as (
select
problems.*,
max(status_id) status_id
from problems
left join tasks on tasks.problem_id = problems.id
group by problems.id, problems.title
) select problem_status.id, problem_status.title, statuses.title
from problem_status
left join statuses on statuses.id = problem_status.status_id
order by problem_status.id;
//Выбираем все категории с базы данных
$stmt = $pdo->prepare("SELECT * FROM category WHERE id=:id OR name=:name");
$stmt->execute(['id'=> $id, 'name'=> $name]);
$res = $stmt->fetchAll(PDO::FETCH_ASSOC);
//Выводим категории по колонке имени в базе
foreach ($res as $row) {
echo '<a href="/"><b>' . $row['id'] . '</b></a><br>' . PHP_EOL;
}