There's a couple more questions,
First read 1000 data from the Customer table,
From the order form, read out the latest order records for each of the 1000 customers,
From the service table, read the latest service records for each of the 1000 customers.
How should this code be written, which is the best solution?
Reply content:
There's a couple more questions,
First read 1000 data from the Customer table,
From the order form, read out the latest order records for each of the 1000 customers,
From the service table, read the latest service records for each of the 1000 customers.
How should this code be written, which is the best solution?
This means that you check the 1000 customers the latest transaction records, it is recommended to write down the latest order ID and service ID of each customer (you can consider using the cache, you can also add two fields directly in the user table), so that you can use in (IDs) to find out, 1000 memory requirements are not very large, Can be directly detected to traverse in the code.
# sqlselect * from order where order_id in (order_ids)# then phpforeach($orders as $order) { foreach($customers as $customer) { if ($customer->getCustomerId() == $order->getCustomerId()) { //... } }}