Welcome Guest, Not a member yet? Register   Sign In
searching with LIKE
#1

[eluser]Peter Dräxler[/eluser]
Hi guys.

PHP:
Code:
function like_find($keywords, $limit = 0, $offset = 0)
    {  
        $this->db->select('products.*, suppliers.Name AS Supplier');
        $this->db->from('products, suppliers');
        $this->db->where('products.Supplier = suppliers.Id');
        
        $this->db->like('products.Code', $keywords);
        $this->db->or_like('products.PartNo', $keywords);
        $this->db->or_like('products.EAN', $keywords);
        $this->db->or_like('products.Name', $keywords);
        $this->db->or_like('products.Manufacturer', $keywords);

        $this->db->order_by('products.Price', 'ASC');
        
        if($limit > 0)
        $this->db->limit($limit, $offset);
        
        return $this->db->get()->result('array'). exit($this->db->last_query());
    }

SQL:
Quote:SELECT `products`.*, `suppliers`.`Name` AS Supplier FROM (`products`, `suppliers`) WHERE `products`.`Supplier` = suppliers.Id AND `products`.`Code` LIKE '%text%' OR `products`.`PartNo` LIKE '%text%' OR `products`.`EAN` LIKE '%text%' OR `products`.`Name` LIKE '%text%' OR `products`.`Manufacturer` LIKE '%text%' ORDER BY `products`.`Price` ASC

I want 1 line of every suitable product but it get 9 lines of every product :-(

Please help!

Thank's


Messages In This Thread
searching with LIKE - by El Forum - 09-21-2010, 02:52 PM
searching with LIKE - by El Forum - 09-21-2010, 04:38 PM
searching with LIKE - by El Forum - 09-21-2010, 04:44 PM
searching with LIKE - by El Forum - 09-21-2010, 05:16 PM
searching with LIKE - by El Forum - 09-22-2010, 07:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB