4
이 번 만 foo6
값마다 상위 키 상이한 것을 알 수 초래할 조인내부 배열이 배열 찾고
Array
(
[0] => Array
(
[foo1] => Apple
[foo2] => Banana
[foo3] => Carrots
[foo4] => Deer
[foo5] => Feather
[foo6] => Grapes
)
[1] => Array
(
[foo1] => Apple
[foo2] => Banana
[foo3] => Carrots
[foo4] => Deer
[foo5] => Feather
[foo6] => Heater
)
[2] => Array
(
[foo1] => Apple
[foo2] => Banana
[foo3] => Carrots
[foo4] => Deer
[foo5] => Feather
[foo6] => Quail Eggs
)
)
질의 :
SELECT
tpp.page_master_properties_style AS foo1,
tpp.page_master_properties_bg AS foo2,
tpp.page_master_properties_data AS foo3,
tpp.page_properties_style AS foo4,
tpp.page_properties_bg AS foo5,
tpp.page_properties_data AS foo6,
tobj.objects_script AS foo6
FROM templates t
INNER JOIN category tc
ON t.category_id = tc.category_id
INNER JOIN page_properties tpp
ON t.templates_id = tpp.templates_id
INNER JOIN objects tobj
ON t.templates_id = tobj.templates_id
WHERE
t.templates_id = ?
? = 1
이것 테이블 개체에 templates_id
에 대한 복수 항목이 있습니다 :
+--------------+----------------+-----------------+
| objects_id | templates_id | objects_script |
+--------------+----------------+-----------------+
| 1 | 1 | Grapes |
| 2 | 1 | Heater |
| 3 | 1 | Quail Eggs |
| 4 | 2 | Milk |
| 5 | 3 | Lemon |
+--------------+----------------+-----------------+
가 어떤 내장 단수 배열로 foo6
를 결합 할 수 있습니다 MySQL의 기능 예는이 같은 결과를 달성하기 위해 :
Array
(
[foo1] => Apple
[foo2] => Banana
[foo3] => Carrots
[foo4] => Deer
[foo5] => Feather
[foo6] => Array
(
[0] => Grapes
[1] => Heater
[2] => Quail Eggs
)
)
감사! 그러나 이것은'page_properties_data'에 대한 새로운 컬럼을 만들어야 혼란 스럽습니다. –
@LeandroGarcia 아니, 전혀. 쿼리를 실행하고 PHP에서 단일 열을 자체 배열로 분해합니다 (각 행에 대한 더 큰 배열의 요소로) – Fluffeh