cakephp 3 分页器不工作

cakephp 3 paginator doesn't work

我目前正在将此查询与 Cakephp 3 一起用于小型搜索引擎

$query_tweet = $this->Tweet
    ->find()
    ->select([
        'Users.username',
        'Users.avatarprofil',
        'Tweet.contenu_tweet',
        'Tweet.created',
        'Tweet.nb_commentaire',
        'Tweet.nb_partage',
        'Tweet.nb_like',
    ])
    ->where([
        "MATCH(Tweet.contenu_tweet) AGAINST(:search)" 
    ])
    ->where(['private' => 0]) // on ne cherche que les tweets publics
    ->bind(':search', '$search')
    ->order(['Tweet.created' => 'DESC'])
    ->contain(['Users']);

此查询完美无缺,但我想像这样使用分页器

$this->set('resultat_tweet', $this->Paginator->paginate($query_tweet, ['limit' => 8]));

我得到

Error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

如果您使用 SQL 关键字作为 table 列名称,您可以在 config/app.php.[=14= 中为数据库连接启用标识符引用]

SQL 查询:

SELECT
    Users.username AS `Users__username`,
    Users.avatarprofil AS `Users__avatarprofil`,
    Tweet.contenu_tweet AS `Tweet__contenu_tweet`,
    Tweet.created AS `Tweet__created`,
    Tweet.nb_commentaire AS `Tweet__nb_commentaire`,
    Tweet.nb_partage AS `Tweet__nb_partage`,
    Tweet.nb_like AS `Tweet__nb_like` 
FROM
    tweet Tweet 
    LEFT JOIN
        users Users ON Users.username = (Tweet.user_id)
WHERE (
    MATCH(Tweet.contenu_tweet) AGAINST(:search) 
    AND private = :c0
)
ORDER BY
    Tweet.created DESC
LIMIT
    8 OFFSET 0

我在 PHPmyadmin 中尝试了这个查询并且它有效,我有很多测试来查看我是否得到搜索并且我有它

我真的不知道有什么问题,我在其他页面上使用分页器并且它可以工作

最后,我通过创建一条新路线得到了我想要的,我不再使用了str_replace

最终代码

              <?= $this->Paginator->options([
'url' => ['-'.$search.'']

]);

       echo $this->Paginator->next('Next page'); ?>

和新路线

Router::connect('/search/index/-:string',['controller' => 'Search', 'action' => 'index']);

非常感谢所有帮助过我的人,尤其是 Mathew Foscarini