there is a usr table containing uid,username
business table 1, the information stored are fields uid,username
business table 2, and only uid,
(multiple data in business table 2 corresponds to one data in business table 1)
the environmental background of the problem and the method you try
existing: query traverses business table 2, the data is an array of list, you also need to assemble username, on list to display
method one is to query username;
according to each list to database usr table according to uid, the second is to first traverse query business table 1, use an empty array arr,key to store username, corresponding to value username, to traverse list, use array_key_exists to determine whether uid is one of the keys of arr, and if so, get arr [uid] as username
questions
The second advantage of the method is that it avoids multiple database queries of username, but there are doubts about using the key of an empty array to store uid,. If the uid value is very large, such as 10000, will this involve the memory problem of the php array (I don"t know much about this)
I also want to know if method 2 has any other shortcomings, and if so, is there any other better processing method