Задать вопрос
@Optiks

SQL и JSON/PHP с LUA или запросом, как вывести нужный тип данных?

Использую запрос
local data = dbPoll(dbQuery(db,"Select common_commerce_order.order_number As column1,
From_UnixTime(common_commerce_order.created) As column2,
common_commerce_order.status As column3,
common_node.title As column4,
common_commerce_product.title As column5,
common_commerce_line_item.quantity As column6,
common_field_data_commerce_unit_price.commerce_unit_price_data As column7,  -- Вот мучительная мной строка JSON или другого формата
common_field_data_commerce_unit_price.commerce_unit_price_amount As column8,
common_field_data_commerce_order_total.commerce_order_total_amount As column9,
common_commerce_order.mail As column10,
common_field_data_field_profile_street.field_profile_street_value As column11,
common_field_data_field_profile_house.field_profile_house_value As column12,
common_field_data_field_profile_apartment.field_profile_apartment_value As column13,
common_field_data_field_profile_region.field_profile_region_value As column14,
common_field_data_field_profile_city.field_profile_city_value As column15 
From common_commerce_order Inner Join common_field_data_commerce_order_total On common_field_data_commerce_order_total.entity_id = common_commerce_order.order_id Inner Join common_field_data_commerce_line_items On common_field_data_commerce_line_items.entity_id = common_commerce_order.order_id Left Join common_commerce_line_item On common_commerce_line_item.line_item_id = common_field_data_commerce_line_items.commerce_line_items_line_item_id Left Join common_field_data_commerce_unit_price On common_field_data_commerce_unit_price.entity_id = common_field_data_commerce_line_items.commerce_line_items_line_item_id Inner Join common_field_data_commerce_customer_shipping On common_field_data_commerce_customer_shipping.entity_id = common_commerce_order.order_id Inner Join common_field_data_commerce_customer_billing On common_commerce_order.order_id = common_field_data_commerce_customer_billing.entity_id Inner Join common_commerce_customer_profile On common_commerce_customer_profile.profile_id = common_field_data_commerce_customer_shipping.commerce_customer_shipping_profile_id Left Join common_field_data_field_profile_street On common_field_data_field_profile_street.entity_id = common_commerce_customer_profile.profile_id Left Join common_field_data_field_profile_apartment On common_field_data_field_profile_apartment.entity_id = common_commerce_customer_profile.profile_id Left Join common_field_data_field_profile_house On common_field_data_field_profile_house.entity_id = common_commerce_customer_profile.profile_id Left Join common_field_data_field_profile_region On common_field_data_field_profile_region.entity_id = common_commerce_customer_profile.profile_id Left Join common_field_data_field_profile_city On common_field_data_field_profile_city.entity_id = common_commerce_customer_profile.profile_id Inner Join common_commerce_product On common_commerce_product.sku = common_commerce_line_item.line_item_label Left Join common_field_data_commerce_price On common_field_data_commerce_price.entity_id = common_commerce_product.product_id Left Join common_field_data_field_displ_products On common_field_data_field_displ_products.field_displ_products_product_id = common_commerce_product.product_id Left Join common_field_data_field_displ_brand On common_field_data_field_displ_brand.entity_id = common_field_data_field_displ_products.entity_id Left Join common_node On common_node.nid = common_field_data_field_displ_brand.field_displ_brand_target_id 
Where
common_commerce_order.status = 'completed' And common_commerce_order.order_number = 81528"),-1)


в JSON или другом формате нахожу такую таблицу
a:1:{
	s:10:"components";
	a:2:{
		i:0;
		a:2:{
			s:4:"name";
			s:10:"base_price";
			s:5:"price";
			a:4:{
				s:6:"amount";
				s:5:"17890";  -- Нужные мне данные
				s:13:"currency_code";
				s:3:"RUB";
				s:4:"data";
				a:1:{
					s:10:"components";
					a:0:{}
					}
				s:8:"included";
				b:1;
				}
			}
		i:1;
		a:3:{
			s:4:"name";
			s:8:"discount";
			s:5:"price";
			a:3:{
				s:6:"amount";
				i:0;
				s:13:"currency_code";
				s:3:"RUB";
				s:4:"data";
				a:0:{}
				}
			s:8:"included";
			b:1;
			}
		}
	}


Как мне вывести только amount?
Хотелось бы знать как и просто SQL запросом, так и через LUA.
  • Вопрос задан
  • 76 просмотров
Подписаться 1 Простой 2 комментария
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы