Welcome Guest, Not a member yet? Register   Sign In
No Comparison in using Where()
#1

[eluser]kb1ibh[/eluser]
the following is the code i'm trying to execute:

Code:
public function lot_Count($firstfour)
{
    $this->db->where('SUBSTR(Lot_Number FROM 1 FOR 4)', $firstfour);
    $count = $this->db->count_all_results('Alfa_Order_Details');    
}

the proper argument that would be passed in would be "F21X", and when this is done, by having the MySQL server log everything, i've discovered CI is generating this SQL statment:

Code:
SELECT COUNT(*) AS `numrows` FROM (`Alfa_Order_Details`) WHERE SUBSTR(Lot_Number FROM 1 FOR 4) 'F21X'

There is no equality in the WHERE section, so the query fails... if i copy the query over to Phpmyadmin, and add the '=' it works fine! any ideas? Bug?
#2

[eluser]danmontgomery[/eluser]
Code:
$this->db->where('SUBSTR(Lot_Number FROM 1 FOR 4) =', $firstfour);




Theme © iAndrew 2016 - Forum software by © MyBB