- Выберите список shop_id, принадлежащий user_id
- Выберите список продуктов, затем принадлежащий shop_id и user_id
- Затем он попадет в один массив.
Код: Выделить всё
user_id
-> shop_id
-> products
[0] ->product_name1
[1] -> product_name2`
Код: Выделить всё
Table : at_order
+----+------------+-----------+------------+
| id | user_id | shop_id | product-id |
+----+------------+-----------+------------+
| 1 | 3 | 3 | 32|
| 2 | 3 | 3 | 24|
| 3 | 3 | 4 | 3 |
| 4 | 4 | 3 | 8 |
| 5 | 4 | 5 | 4 |
| 6 | 4 | 6 | 1 |
+----+------------+-----------+------------+
Код: Выделить всё
function main ()
{
SELECT
`shop_id`
FROM (`at_order`)
WHERE `user_id` = '3'
GROUP BY `shop_id`;
one($shop_id,$user_id);
}
function one ()
{
SELECT
`product_id`,
`order_status`
FROM (`at_order`)
WHERE `user_id` = '3'
AND `shop_id` = '5';
two($shop_id,$product_id);
}
function two ()
{
SELECT *
FROM (`at_product`)
WHERE `product_id` = '35'
AND `shop_id` = '5'
}
Подробнее здесь: https://stackoverflow.com/questions/195 ... odeigniter
Мобильная версия