Welcome Guest, Not a member yet? Register   Sign In
Active record order_by the result of multiplying two fields
#2

(This post was last modified: 11-18-2014, 04:41 PM by twpmarketing.)

$this->db->order_by("project_units.price_min * rate", "asc");

From the 3.0 User Guide
"Lets you set an ORDER BY clause.

The first parameter contains the name of the column you would like to order by.
The second parameter lets you set the direction of the result. Options are ASC, DESC AND RANDOM."


Use the field name itself, not the computed value.
$this->db->order_by("project_units.price_min", "asc");
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply


Messages In This Thread
RE: Active record order_by the result of multiplying two fields - by twpmarketing - 11-18-2014, 04:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB