$sql_request = "$sql_find AND (
title LIKE '%{$query}%'
OR xfields LIKE '%genre|{$query}%'
OR xfields LIKE '%year|{$query}%'
) ORDER BY $order_by LIMIT $search_start,{$config['search_number']}";
$db->query("
SELECT * FROM " . PREFIX . "_post
WHERE " . PREFIX . "_post.approve = 1
{$this_date}
AND (
title LIKE '%{$query}%'
OR xfields LIKE '%new|{$query}%'
OR xfields LIKE '%year|{$query}%'
)
ORDER BY date DESC
LIMIT 5
");
WHERE (title LIKE '%Rembo%' OR SUBSTRING_INDEX( SUBSTRING_INDEX( xfields, 'title_en|', -1 ) , '||', 1 ) LIKE '%Rembo%' OR SUBSTRING_INDEX( SUBSTRING_INDEX( xfields, 'title_ru|', -1 ) , '||', 1 ) LIKE '%Rembo%')
// Функция для извлечения значения доп. поля
function get_xfield_value($field_name) {
return "SUBSTRING_INDEX(SUBSTRING_INDEX(xfields, '{$field_name}\"', -1), '\"', 1)";
}
$conditions = ["title LIKE '%{$query}%'"];
$custom_fields = ['new', 'year']; // Добавляйте новые поля сюда
foreach ($custom_fields as $field) {
$conditions[] = get_xfield_value($field) . " LIKE '%{$query}%'";
}
$where_clause = implode(' OR ', $conditions);
$db->query("SELECT id, short_story, title, date, xfields, alt_name, category FROM " . PREFIX . "_post WHERE " . PREFIX . "_post.approve=1" . $this_date . " AND ({$where_clause}) ORDER by date DESC LIMIT 5");
