0
How to pull data from database exactly and accordingly??? Php
how to avoid pulling data which are not related to the logged in user informations his/her history e.t.c
3 Respuestas
+ 1
You should definitely not limit yourself to the availability of one person. You can find help on "Stack Overflow", which is a place with a lot of experienced people.
0
The norm is to write your queries in a way that you only get the necessary data. Any other way is a waste of resources.
So if you need to process the user name and email from a table with many columns, don't select everything ("*"), but strictly the two columns you need.
GOOD: SELECT username, email FROM users WHERE user_id=1
BAD: SELECT * FROM users WHERE user_id=1
WORSE: SELECT * FROM users
Another example: when you need the 10 latest registered users, you have to be specific to both selecting the users and the required data that you need to use. Let's say you want to make a list of these users and you want to be able to click on their name to go to their profiles. The least amount of data you need is their IDs and their usernames.
GOOD: SELECT id, username FROM users ORDER BY regDate DESC LIMIT 10
BAD: SELECT id, username FROM users ORDER BY regDate DESC
WORSE: SELECT * FROM users ORDER BY regDate DESC
OMG: SELECT * FROM users
The point is to learn how to be as specific as possible in your SQL queries, so you don't have to do the least amount of data processing with your language (in this case PHP). This is essential for performance.
Sadly, the SQL course here doesn't have any information about indexes, which are very handy to speed up queries that are already good. Also very important is the database design - from choosing the proper character sets and collations, to efficiently create the tables and their columns for good indexing. Anyway, all the courses here are rather simple, but even mentioning data types and indexes would have been helpful.
0
thank you nicolae can you give me your email for more contact