fotobleu Posted October 31, 2007 Share Posted October 31, 2007 the scenario is , i have a imaginary site that will get high traffic, what is best for performance, and best practice lets say i have some data for each user such as (name, age, sex) which is a wise way to process and store this data? 1st way create a object and serialize it to one field in a database, and always serialize it and unserialize it when i want to work with the data or 2nd way just store each piece of data in the database in it's own field, and always query what you need and work with it thanks in advance, i've been coding for a while now, and im reading all this materials on different way of doing things, but i would like to find out the benefits of one way versus the other, if anyone has any good resources i could read where i can get info on benefits and best practices, please let me know, i will greatly apreciate it Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted October 31, 2007 Share Posted October 31, 2007 Number two. That way you can select some of the data without selecting all. Also you don't have to use resources to serialize and unserialize the objects all the time. Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted November 1, 2007 Share Posted November 1, 2007 Yes, I agree...#2. Just think about what you would have to do to create a search function to say "I want every user with an age of 25-30". What would you have to do for each one? #2 would be a lot easier to work with, don't you think? Quote Link to comment Share on other sites More sharing options...
fotobleu Posted November 1, 2007 Author Share Posted November 1, 2007 great, thanks for the response, what about preparing the data for output in html for ex: is it good to build a huge string like this and then run it trough one echo statement $echoStr .= '<div>some more html tags,some values from the db</div>'; $echoStr .= '<div>some more html tags</div>'; $echoStr .= '<div>some more html tags</div>'; $echoStr .= '<div>some more html tags</div>'; //the last statement in php tags echo $echoStr; or individual echos echo '<div>some more html tags, saome values from the db</div>'; echo '<div>some more html tags</div>'; echo '<div>some more html tags</div>'; echo '<div>some more html tags</div>'; thanks Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted November 1, 2007 Share Posted November 1, 2007 I'd do echo <<<EOF <div>some more html tags, saome values from the db</div> <div>some more html tags</div> <div>some more html tags</div> <div>some more html tags</div> EOF; Quote Link to comment Share on other sites More sharing options...
websiterepairguys Posted November 18, 2007 Share Posted November 18, 2007 I'd do echo <<<EOF <div>some more html tags, saome values from the db</div> <div>some more html tags</div> <div>some more html tags</div> <div>some more html tags</div> EOF; YIKES I would not put the HTML and the PHP in the same file. But thats just me. Check out http://smarty.php.net Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.