Regarding php business logic and mysql optimization issues
赵。。。。赵得住
赵。。。。赵得住 2018-07-11 11:43:28
0
3
1215

There is a usr table that stores uid, username
Business table 1, the stored information has the field uid, username
Business table 2, the stored information is only uid,
(Business table 2 has multiple fields The data corresponds to one piece of data in business table 1)

Existing: The query traverses business table 2, the data is an array list, and username needs to be assembled on the list to facilitate front-end display
Method one is that each list is based on uid goes to the usr table of the database to query username;
The second method is to first traverse the query business table 1, use an empty array arr, the key stores uid, the corresponding value stores username, traverse the list, use array_key_exists to determine whether uid is one of the keys in arr , if so, get arr[uid] as username

The second advantage is that it avoids multiple database queries for username, but there is a problem with using the key of an empty array to store uid. If the uid value is very large, such as 10000, Will this involve PHP array memory issues (I don’t know much about this aspect)
I also want to know if there are any other shortcomings in the second method. If so, is there any other better way to deal with it



赵。。。。赵得住
赵。。。。赵得住

reply all(2)
You bad bad

Linked list query. External link

Summer

Just query the linked tables


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template