1、添加扩展路径
2、调用yml存储的分页
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit(config('node.settings')->get('items_per_page'))
详细代码如下:
<?php
$select = db_select('node', 'n')
->fields('n', array('nid', 'sticky', 'created'))
->condition('n.promote', 1)
->condition('n.status', 1)
->orderBy('n.sticky', 'DESC')
->orderBy('n.created', 'DESC')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit(config('node.settings')->get('items_per_page'))
->addTag('node_access');
?>