Using MySQL multi query and creating a counter variable in PHP

cntI had this problem where I need to change the order of the products we have and ¬†update them from the most popular to least popular. So what I did, I declared a variable that will act as a counter and set the column order_num to the current value of the counter. Here’s what I did:

You can also order specific record by adding an IN clause like:

Adding PHP Mobile Detect in CakePHP1.3 as a component

cake-logoIt seems that the library is not available for old version of CakePHP specifically in 1.3 only in 2.x. So what I did I converted the library as a component, there’s is nothing special about the conversion actually only if you are new to the Framework. Just download the file and unzip it, put it in your /app/controller/components directory.

Download >> Mobile Detect

How to use it:

In one of your controllers, append it in your $components variable like:

To download the original file go here.