Welcome Guest, Not a member yet? Register   Sign In
WHERE is not working.
#1

(This post was last modified: 01-24-2015, 01:43 AM by jaysondotp.)

Hi

i have the following code below that mysql WHERE FUNCTION Is NOT WORKING whine i use OR_LIKE. but whine i try to remove all OR_LIKE it well work perfect.

Code:
$this->db->select('users.*,query1.*,query_price.*,');
$this->db->from('query_price');
$this->db->join('query1','query1.Barcode = query_price.Barcode', 'left');
$this->db->join('users','query_price.username = users.username', 'left');
$this->db->order_by('query_price.price_id','desc');
    
$this->db->where('query_price.approve !=',''); // THIS IS NOT WORK //

$this->db->like('query1.description',$search_keyword);
$this->db->or_like('query_price.Barcode',$search_keyword);
$this->db->or_like('query_price.new_cost',$search_keyword);
$this->db->or_like('query_price.new_dp',$search_keyword);
$this->db->or_like('query_price.new_srp',$search_keyword);
$this->db->or_like('query_price.new_reg',$search_keyword);
$this->db->or_like('query_price.dis_a',$search_keyword);
$this->db->or_like('query_price.dis_b',$search_keyword);
$this->db->or_like('query_price.date',$search_keyword);
$this->db->or_like('query_price.prepare',$search_keyword);

i try different methods but im NOT luck, and im hoping that i get the answer here.

Thanks in advance..
Reply
#2

(This post was last modified: 01-24-2015, 02:54 AM by sv3tli0.)

Sorry but I can't test at moment so only can give you idea..
Try replacing first like with or_like ..
When you have where cause already it must be or_like..

(to be sure echo $this->db->last_query(); after the query to see what sql query is generated.. )
Best VPS Hosting : Digital Ocean
Reply
#3

Try this

PHP Code:
$this->db->where('query_price.approve !=',''false); 

Reply
#4

(This post was last modified: 01-24-2015, 09:56 AM by ivantcholakov. Edit Reason: A typo )

@jaysondotp Are you trying this on CodeIgniter 3?

Edit: Watch the parentheses control.

IMO

CI2: You need to switch to raw SQL with proper escaping.

CI3: You need to correct the query builder code by using group_start(), and group_end() methods (variations *_group_start() if needed). See http://www.codeigniter.com/userguide3/da...roup_start

Check what SQL actually is generated and whether it is as you expected to be.

Edit 2:

Examples: http://www.codeigniter.com/userguide3/da...y-grouping
Reply




Theme © iAndrew 2016 - Forum software by © MyBB