腾讯云优惠券

通过数据库助手函数db调用置顶文章ID的实例

人气:337 更新:2022-12-30

查询文章ID列表

$ids = db('info_meta')->where('info_meta_key','cms_top')->where('info_meta_value','1')->limit(100)->column('info_id');
dump($ids);

查询文章列表

$result = cmsSelect([
    'field'      => 'info_name,info_slug,info_action,info_create_time',
    'id'         => ['in',db('info_meta')->where('info_meta_key','cms_top')->where('info_meta_value','1')->limit(100)->column('info_id')],
    'status'     => 'normal',
    'limit'      => 100,
    'with'       => 'info_meta',
    'sort'       => 'info_id',
    'order'      => 'desc',
]);
dump($result);