function buildTree($flatArray) {
$tree = [];
$stack = [];
foreach ($flatArray as $item) {
$node = $item;
$node['CHILD'] = [];
while (!empty($stack) && end($stack)['DEPTH_LEVEL'] >= $item['DEPTH_LEVEL']) {
array_pop($stack);
}
if (empty($stack)) {
$tree[] = $node;
} else {
end($stack)['CHILD'][] = $node;
}
$stack[] = &$node;
}
return $tree;
}
$sourceArray = []; // ваш исходный массив
$resultArray = buildTree($sourceArray);
print_r($resultArray);
queryBuilder.where("orders.status = :status", {
status: query.status,
}).andWhere(
new Brackets((qb) => {
qb.orWhere("orders.title LIKE :title", {
title: `%${query.name}%`,
}).orWhere("orders.description LIKE :description", {
description: `%${query.name}%`,
});
})
);
queryBuilder.where(
"orders.status = :status AND (orders.title LIKE :title OR orders.description LIKE :description)",
{
status: query.status,
title: `%${query.name}%`,
description: `%${query.name}%`,
}
);