I just discovered this and it is wonderful. I hope it is not dangerous/wrong or ill advised. Thought I would mention it and perhaps suggest the documentation should mention it, as it is very handy to know.
I had an online shop where I wanted to order the sale items by the amount saved, i.e. product price minus sale price. I was struggling for a while on how to do this when I had an idea to try this - and it worked perfectly.
Code:
$this->db->order_by('product_price - product_sale_price', 'DESC');
The wonders of codeigniter, one line did it all.
I was about to change the admin adding of sale price to add in a column on the product table for saving amount, which would have been a pain.
I am personally very happy with this! Thank you CI for being so perfect!
Best wishes,
Paul.