使用 Yii2 通过 elasticsearch 限制查询
Limit query with elasticsearch using Yii2
我在 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() 函数。
我在 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() 函数。