Welcome Guest, Not a member yet? Register   Sign In
DB Active Record: where / or_where return different result
#1

[eluser]tkaw220[/eluser]
Hi,

When working with Active Record, I found below issue:

1)
Code:
$q = $this->db
           ->where('format', 'reader')
           ->or_where('format', 'reader with 3D goggles')
           ->order_by('brand, format, title', 'asc')
           ->get('products');

Query:
Code:
SELECT * FROM (`products`) WHERE `format` = 'reader' OR `format` = 'reader with 3D goggles' ORDER BY `brand`, `format`, `title` asc

Return products properly.

2)
Code:
$q = $this->db
           ->where('format', 'reader')
           ->or_where(array('format' => 'reader', 'format' => 'reader with 3D goggles'))
           ->order_by('brand, format, title', 'asc')
           ->get('products');

Query:
Code:
SELECT * FROM (`products`) WHERE `format` = 'reader' OR `format` = 'reader with 3D goggles' ORDER BY `brand`, `format`, `title` asc

Return only products match the second parameter, which is reader with 3D goggles.

I do not understand how two codes generated one same SQL query, but return result differently. Would appreciate if someone could clarify this.

Thank you for your time.


Messages In This Thread
DB Active Record: where / or_where return different result - by El Forum - 06-01-2011, 09:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB