For two tables, is it generally a direct association or two queries, such as a user table or a user education table {code? Isn't it possible to directly associate the database? Is it possible to allow php to join the database more than once? For other tables, such as busy businesses or services... for two tables, it is usually directly associated or found twice before association, such as user tables and user education tables.
$user_ids = query(select id from users);$background = query('select * from background where uid in '.implode(',',$user_ids));
Do you need this? Isn't it possible to directly associate the database? Is it possible to allow php to join the database more than once?
For other tables, such as busy businesses or busy businesses, do you have to treat them separately?
Reply content:
For two tables, whether to directly associate the table or perform association after two queries, such as the user table and user education table
$user_ids = query(select id from users);$background = query('select * from background where uid in '.implode(',',$user_ids));
Do you need this? Isn't it possible to directly associate the database? Is it possible to allow php to join the database more than once?
For other tables, such as busy businesses or busy businesses, do you have to treat them separately?
Not tested. However:
- The database is easy, and the task of your PHP program is heavier. After all, databases that query tables are more professional.
- Added Network data transmission.
- If you get a large number of data entries, Your PHP needs to generate a large string and transmit it to the database. Then the database has to spend more time Parsing Memory and CPU. If your id is complex, you may make a mistake.
- If the data changes between two queries result in inconsistent results with the query results of one join table, will this affect your business logic?
If the access volume is large enough, this can indeed reduce the pressure on the database, but this will increase the complexity and it is not recommended to optimize it too early.
Manage SQL resources and provide placeholders as configured in the configuration file;
Design a parser module to obtain parameters and replace placeholders;
Execute the query and return the results. You can also input the type to perform reflection on the query results;
The combined query is better. After all, I/O operations are performed separately.