Open Source Blog | Professionals Blog | Blog Sites | Technology Blog

This is Open Source Universe Blog. You can share your views related to Open Source.
Tags >> performance

I recently worked on the project related to improve the website speed. When I analyzed the files I found that it used a lot of php code which can easily replaced by mysql. There were a scenario where we sort the record in particular order e.g. 2,0,1 and it was accomplished with the help of PHP code.

When I checked the mysql manual I found it can be done easily using ORDER BY FIELD

For e.g. If you have 3 priorities Low, Normal, High and you want to display High records first and then Normal and then Low. We used below query for that and it worked very well and it improved the website loading time.

Select * from table_name ORDER BY FIELD(priority_record, ‘High’,’Normal’,’Low’);


Free - Magazines

Like our work? Support Us

Chat

Please login to be able to chat.

Feed Subscription

Enter your email address:

Delivered by FeedBurner

Feedback Form