【问题标题】:How to use findAllBy() with pagination?如何将 findAllBy() 与分页一起使用?
【发布时间】:2015-03-13 14:56:15
【问题描述】:

我正在开展一个项目,我想根据他们在个人资料中所说的技能来搜索他们。我想使用 findAllBy(); 函数,但我不确定它如何与 CakePHP 打包的 Pagination 组件一起使用。

【问题讨论】:

  • 不要使用findAllBy,而是使用find 和所需的condition 子句。然后将该子句与分页器一起使用。

标签: php cakephp pagination cakephp-2.0


【解决方案1】:

只需在 Paginator 中使用条件,例如:

public function skills($skill = null){
  $this->Paginator->settings = array(
      'conditions' => array(
          'skill LIKE' => '%'.$skill.'%'
       )
  );
  $people = $this->Paginator->paginate('People');
  $this->set('people', $people);
}

【讨论】:

    猜你喜欢
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    • 2023-03-26
    • 2020-03-07
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多