jonniejoejonson Posted August 31, 2008 Share Posted August 31, 2008 Can someone tell me how they do this. On facebook, if you do a search for a friend, on the results page will be a list of users that match that name. By each user there will be options of things you can do. If you are already friends with that person, the options are different… therefore when facebook does a search it must also cross reference the search results with your friends table… or do you think that when you login they store all your friends in a session?… and then cross reference the search results with your session? Another example pointing towards the session theory is that, when you start typing a friends name in a search box it predicts the name you are typing…. This would indicate to me that when you login, face book grabs all your friends names and Id’s and stores them in a session, rather than having to do more complex database queries? Can anyone tell me how they think it is done. Kind regards J Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/ Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 They query is conditional but they probably aren't running MySQL but Oracle so they structure of querying is a lot different and as you expect tables are lot more dependent on each other. You could select via a GROUP_CONCAT all you friend's id in the mysql query and then if a user's ID matches a value in the GROUP_CONCAT it shows the special buttons for your friends. Its not difficult to do just a bunch of ways to do it depending on your DB strucutre Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/#findComment-630626 Share on other sites More sharing options...
jonniejoejonson Posted September 1, 2008 Author Share Posted September 1, 2008 Okay thanks for your response, That would be how i would compare friend id's in my search query, however if the friend id's are stored in a session then it would save on having to do an extra database query... plus it would explain the predictive text... if you start typing in the search box (on every page) it predicts your friends names. They aren't querying the database every time you type a letter, so that must mean they either query and get all your friend Id's before each page loads, or they must just store this in a session?... do you think this is correct tor am i just talking crazy? at the max the session would habve to store 5000 id's (max nos of friends)... that would be okay right? thanks for you help. Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/#findComment-630900 Share on other sites More sharing options...
valtido Posted September 1, 2008 Share Posted September 1, 2008 they use ajax to do that. here is an example PHP MySQL http://www.w3schools.com/php/php_ajax_suggest.asp as for database set up you use 2 tables Users & Friends users table UID Firstname blabla blablabla Friends UID1 UID2 Status UID1 is the person who has asked the UID2 to accept and the default status would be pending... untill the user accepts then they are friends otherwise if rejected delete the entry bla bla bla hope it helps Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/#findComment-630903 Share on other sites More sharing options...
jonniejoejonson Posted September 1, 2008 Author Share Posted September 1, 2008 thanks for your response, and im not saying you are wrong about the ajax for predictive text, but the response time is instantaneous... surely my friends names are already stored on my machine?. Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/#findComment-630909 Share on other sites More sharing options...
valtido Posted September 1, 2008 Share Posted September 1, 2008 not necessary sometimes they know who you are and they know what sort of actions you will take but they dont know which order right. so they can also load all of ur friends and hide them using css that can make it faster. you see because they have the money they also have much more powerful servers to deal with those. look at the youtube search. it has to deal with much more querries and more diverse load of crap lol they do use ajax its the only way u can get data that way unless you have hidden them with css lol style="display: none;" then manipulate it using javascript lol not saying i know it 100% but its the most likely way they have done it. click on that page that i gave you and you will see that it too is almost instant. Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/#findComment-630919 Share on other sites More sharing options...
jonniejoejonson Posted September 1, 2008 Author Share Posted September 1, 2008 Thanks again for your continued response... and i agree that the example you showed is good, however it isn't searching a databse for the names, it searching a php array of names... which would make it quicker... but surely if when a user logs in i store that users friends id and names in a session, I would be able to use just javascript to make the predictive text, becauase all the names would already be on the users machine. thanks again. Link to comment https://forums.phpfreaks.com/topic/122148-how-have-they-done-this/#findComment-630930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.