Can I do this with just SQL?
- by Josh
At the moment I have two tables, products and options.
Products contains
id
title
description
Options contains
id
product_id
sku
title
Sample data may be:
Products
id: 1
title: 'test'
description: 'my description'
Options
id: 1
product_id: 1
sku: 1001
title: 'red'
id: 2
product_id: 1
sku: 1002
title: 'blue'
I need to display each item, with each different option. At the moment, I select the rows in products and iterate through them, and for each one select the appropriate rows from options. I then create an array, similar to:
[product_title] = 'test';
[description] = 'my description';
[options][] = 1, 1001, 'red';
[options][] = 2, 1002, 'blue';
Is there a better way to do this with just sql (I'm using codeigniter, and would ideally like to use the Active Record class)?