Active record order_by the result of multiplying two fields |
I like your idea of running the calculation in the select and then ordering on the new named field. It would be a nice clean way to do it. Perhaps you know how I could get this to work with select_min, which when translated into SQL already has the 'as [field_name]' included. This is the value that needs to be multiplied by the rate.
Code: $this->db->select_min("project_units.price_min") Code: MIN(`project_units`.`price_min`) AS price_min I it possible to nest active record queries? Thanks (11-18-2014, 05:13 PM)bclinton Wrote: I believe you should be able to order by the result of a calculation. To debug it, log $this->db->last_query() to make sure Active Record is giving you what you want. |
Messages In This Thread |
Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 04:24 PM
RE: Active record order_by the result of multiplying two fields - by twpmarketing - 11-18-2014, 04:38 PM
RE: Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 04:45 PM
RE: Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 04:54 PM
RE: Active record order_by the result of multiplying two fields - by bclinton - 11-18-2014, 05:13 PM
RE: Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 05:22 PM
RE: Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 06:28 PM
RE: Active record order_by the result of multiplying two fields - by bclinton - 11-18-2014, 06:33 PM
RE: Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 06:39 PM
|