• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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);


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.