我在Yii2中将Elasticsearch与Active Records一起使用。
static function getPosts()
{
return Post::find()
->orderBy('ID desc')
->all();
}
方法find()可以正常工作,但是如果我添加方法limit(),它将停止工作。
static function getPosts()
{
return Post::find()
->orderBy('ID desc')
->limit(20)
->all();
}
如何在Active Records,Elasticsearch和Yii2的查询限制中使用?
问候。
最佳答案
没事
Active Records与limit()函数不兼容。
您必须为此使用query()函数。
关于php - 使用Yii2使用Elasticsearch限制查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36413915/