我在laravel上有疑问
$types=Types::selectRaw('COUNT(property_types.id) as total, property_types.types, property_types.id')
->join('properties', 'property_types.id', '=',
'properties.property_type')
->where('property_purpose', '"Sale"')
->groupBy('property_types.id','property_types.id','property_types.types')
->get();
我没有任何结果
Collection {#383 ▼
#items:[]
我通过-> toSql()更改-> get();我有laravel查询
select COUNT(property_types.id) as total, property_types.types, property_types.id
from `property_types`
inner join `properties` on `property_types`.`id` = `properties`.`property_type`
where `property_purpose` = ?
group by `property_types`.`id`, `property_types`.`id`, `property_types`.`types`
更改?通过变量“销售”复制并粘贴到PhpMyadmin上,我得到了想要的结果
我不知道Laravel Eloquent有什么问题!
答案 0 :(得分:0)
对我有用
$类型=类型:: selectRaw( 'COUNT(property_types.id)为总,property_types.types,property_types.id')
->join('properties', 'property_types.id', '=',
'properties.property_type')
->where('property_purpose', 'Sale')
->groupBy('property_types.id','property_types.id','property_types.types')
->get();