在 ThinkPHP 的 ORM 中,要查询一个字段大于一个数字,小于另一个数字的数据,可以使用 where 方法结合 gtlt 条件进行查询。以下是一个示例:

use think\Model;

class YourModel extends Model
{
    public function yourMethod()
    {
        $result = $this->where('your_field', '>', 10)
                       ->where('your_field', '<', 20)
                       ->select();
        
        return $result;
    }
}

在上述示例中,your_field 是你要查询的字段名,1020 分别是你要比较的两个数字。where 方法用于设置条件,gtlt 分别表示大于和小于。


原文地址: https://www.cveoy.top/t/topic/p50J 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录