- $context = stream_context_create($query);
+ $context = stream_context_create($query_options);
select n.*, -- атрибуты новости
p1.*, -- атрибуты автора
p2.*, -- атрибуты исполнителя
s.* -- атрибуты статуса новости
from news n
join status s on s.statusId = n.statusId
left join people p1 on p1.peopleId = n.authorId
left join people p2 on p2.peopleId = n.executorId
where p1.fullName like :search
or p2.fullName like :search
select *
from news
select n.*, -- атрибуты новости
s.* -- атрибуты статуса новости
from news n
join status s on s.statusId = n.statusId
select n.*, -- атрибуты новости
s.* -- атрибуты статуса новости
from news n
join status s on s.statusId = n.statusId
where s.statusId = :statusId
select n.*, -- атрибуты новости
p1.*, -- атрибуты автора
p2.*, -- атрибуты исполнителя
s.* -- атрибуты статуса новости
from news n
join status s on s.statusId = n.statusId
left join people p1 on p1.peopleId = n.authorId
where p1.fullName like :search
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
/blog/post-url
$uri = trim($_SERVER['REQUEST_URI'], '/'); // обрезать концевые слеши
$segments = explode('/', $uri); // Разбить в массив по слешам
// и простейший роутинг
switch ($segments[0]??null) {
case 'blog':
$slug = $segments[1];
include 'blog.php';
break;
default:
echo 'Homepage';
}
$post = query('SELECT * FROM posts WHERE slug = :slug', ['slug' => $slug]);
if (!$post) {
echo '404';
die;
}
echo $post->title;
echo $post->content;
Я нажимаю добавить картинку, она уходит на сервер, там ей присваивается новое уникальное имя,
'numberposts' => -1
рекурсивно получает все дочерние страницы указанного родителя, если его не указывать, то вернуться лишь те дочерние страницы, у которых parent_id == id родителя:<?php
$id = 1;
$config = [
'parent' => $id,
'post_type' => 'page',
// 'numberposts' => -1,
'post_status' => 'publish',
];
$child = get_pages($config);
if($child) {
foreach($child as $page) {
echo $page->ID;
}
} else {
echo 'У этой страницы нет дочерних страниц.';
}
const data = [ /* ... */ ];
let offset = 0;
while (offset < data.length) {
data[offset + 0];
data[offset + 1];
// ...
data[offset + 7];
offset += 8
}
$filtered_arr = array_filter($arr, function ($el) use ($arr2) {
return !in_array($el['number'], $arr2);
}
});