We have a table with multiple attributes, such as:
TABLE_ATTRIBUTES
ID, Color, Size, Weight
111, Red, XL null
112, null, SM 10
I want to build a method inside my model, that returns the row ID, by checking all the columns for any attributes. For example, if I want to pass 'green', 'SM', '9'.
What's the best way to build this Codeigniter DB Query?
I have something like this, but it's not working:
$this->db->select('id');
->or_where($color === NULL ? 'color IS NOT NULL' : 'color =', $color)
->or_where($size === NULL ? 'size IS NOT NULL' : 'size =', $size)
->or_where($weight === NULL ? 'weight IS NOT NULL' : 'weight =', $weight_10)
$row = $this->db->get('product')->row();