fetchAll("SELECT * FROM {$db->table('slide')} WHERE status = 1 ORDER BY sort_order ASC, id DESC LIMIT 5");
// 产品分类(模型2=产品)
$productChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = 0 AND channel_type = 2 AND is_show = 1 ORDER BY list_order ASC, id ASC LIMIT 8");
// 按分类获取产品
$productByCat = [];
foreach ($productChannels as $pch) {
$products = $db->fetchAll("SELECT * FROM {$db->table('product')} WHERE channel_id = ? AND status = 1 ORDER BY create_time DESC LIMIT 4", [$pch['id']]);
if (!empty($products)) {
$productByCat[$pch['id']] = [
'channel' => $pch,
'products' => $products
];
}
}
// 关于我们内容(取第一个文章模型栏目)
$aboutChannel = $db->fetch("SELECT * FROM {$db->table('channel')} WHERE channel_type = 1 AND is_show = 1 ORDER BY id ASC LIMIT 1");
$aboutArticle = null;
$aboutLitpic = '';
if ($aboutChannel) {
$aboutArticle = $db->fetch("SELECT * FROM {$db->table('article')} WHERE channel_id = ? AND status = 1 ORDER BY create_time DESC LIMIT 1", [$aboutChannel['id']]);
$aboutLitpic = $db->fetch("SELECT litpic FROM {$db->table('article')} WHERE channel_id = ? AND status = 1 AND litpic != '' ORDER BY create_time DESC LIMIT 1", [$aboutChannel['id']]);
}
// 案例(取产品模型作为案例展示)
$caseProducts = $db->fetchAll("SELECT p.*, c.channel_name FROM {$db->table('product')} p LEFT JOIN {$db->table('channel')} c ON p.channel_id = c.id WHERE p.status = 1 AND p.litpic != '' ORDER BY p.create_time DESC LIMIT 4");
// 新闻(文章模型)
$newsArticles = $db->fetchAll("SELECT a.*, c.channel_name, c.id as cid FROM {$db->table('article')} a LEFT JOIN {$db->table('channel')} c ON a.channel_id = c.id WHERE a.status = 1 ORDER BY a.create_time DESC LIMIT 6");
$featuredNews = !empty($newsArticles[0]) ? $newsArticles[0] : null;
$otherNews = array_slice($newsArticles, 1);
require_once __DIR__ . '/_header.php';
?>