Welcome Guest, Not a member yet? Register   Sign In
Calculated WHERE based on database field before realising query
#3

[eluser]jonez[/eluser]
I don't know how with Active Record but you can do a manual query like this:

Code:
$params = array(
    (float)$this->session->userdata('price_min'),
    (float)$this->session->userdata('price_max'),
);

$sql = "
SELECT
    p.*
FROM
    property p
WHERE
    p." . $price . " >= ( ? * p.exchange_rate ) AND
    p." . $price . " <= ( ? * p.exchange_rate )
";

$results = $this->db->query( $sql, $params )->result_array( );

I'm assuming $price is internal, if it's not validate it. If it doesn't work post your empty schema and I'll check the query I haven't tested that.


Messages In This Thread
Calculated WHERE based on database field before realising query - by El Forum - 06-28-2014, 06:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB