2019-12-25 13:52:22 1925次浏览 1条回答 0 悬赏 35 金钱

$query = Order::find();

$query->select('order.id,order.code,order.apply_no,
order.create_time,order.create_id,order.update_time,order.engineer,
order.type,order.store_id,order.status,order.name,order.phone,
order.appointment_time,order.district,order.address,order.remark,
car_install.vin,car_install.license_plate,car_install.car_owner_name,
product_package.name as package_name,driver.code as driver_code,driver.install_place');

$this->load($params);

$query->join('LEFT JOIN',Driver::tableName(),'driver.order_id = order.id AND driver.deleted = 0 ');

if ($this->driverCode){

$query->andFilterWhere([Driver::tableName().'.code'=>$this->driverCode]);

}

$query->orderBy(Order::tableName().'.id desc');

$offset = $page*$pageSize;

$data = $query->limit($pageSize)->offset($offset)->asArray()->all();

打印sql为

SELECT

`order`.`id`, `order`.`code`,
`order`.`apply_no`, `order`.`create_time`,
`order`.`create_id`, `order`.`update_time`,
`order`.`engineer`, `order`.`type`,
`order`.`store_id`, `order`.`status`,
`order`.`name`, `order`.`phone`,
`order`.`appointment_time`, `order`.`district`,
`order`.`address`, `order`.`remark`,
`car_install`.`vin`, `car_install`.`license_plate`,
`car_install`.`car_owner_name`,
`product_package`.`name` AS `package_name`,
`driver`.`code` AS `driver_code`,
`driver`.`install_place`

FROM

`order`

LEFT JOIN car_install ON order.id = car_install.order_id

LEFT JOIN product_package ON car_install.product_id = product_package.id

LEFT JOIN driver ON driver.order_id = order.id

AND driver.deleted = 0

WHERE

(`order`.`code` LIKE '%YK2019122110257981%')

AND (order.customer_id = '152')

AND (order.store_id IN ('10479', '10524'))

AND (order.deleted = 0)

ORDER BY

`order`.`id` DESC

LIMIT 2000

把sql放到数据库执行查询到两条条数据,但是程序执行出来只有一条,想请教是哪里出了问题?

最佳答案

    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
不求而得的往往求而不得
主管

不求而得的往往求而不得 上海

注册时间:2019-05-28
最后登录:2022-03-08
在线时长:18小时17分
  • 粉丝0
  • 金钱135
  • 威望40
  • 积分715

热门问题