【问题标题】:Laravel 5.2 whereBetween not workingLaravel 5.2 whereBetween 不工作
【发布时间】:2016-12-19 04:24:37
【问题描述】:

我正在使用 laravel 5.2 框架,但在此 WhereBetween 中不起作用。我使用的价格范围从 500 到 4000 开始。当我执行查询时会得到空记录,但是当我删除 WhereBetween() 时会得到所有记录。请建议我如何解决这个问题。

$query = Property::query();
        $query->select('properties.property_id', 'properties.property_title', 'properties.description', 'properties.latitude', 'properties.longitude', 'properties.city_name', 'properties.state_name');
        $query->leftjoin('properties_base_season_price_transactions', 'properties_base_season_price_transactions.parent_id', '=', 'properties.property_id');
        $query->leftjoin('properties_availability', 'properties_availability.property_id', '=', 'properties.property_id');
        $query->where('properties.property_category_id', $post_data['categoryid']);
        $query->where('properties.property_sub_category_id', $post_data['subcategoryid']);
        $query->where('properties.city_name',  'LIKE' , '%'.$post_data['city'].'%');
        $query->whereBetween('properties_base_season_price_transactions.price', [500, 4444]);
        $query_output = $query->get()->toArray();

【问题讨论】:

  • properties_base_season_price_transactions.price 的数据类型?
  • @Abhishek 数据类型是 varchar..
  • 数据类型应为integerfloat(或类似的数字数据类型)。

标签: php laravel-5 laravel-5.2


【解决方案1】:

whereBetween好像有问题试试

->whereRaw("properties_base_season_price_transactions.price BETWEEN 500 AND 4444");

【讨论】:

    猜你喜欢
    • 2016-11-27
    • 1970-01-01
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 2016-08-11
    相关资源
    最近更新 更多