Так следующие работыMysql dyanmic значение в качестве псевдонима
$query = "SELECT
A.entity_id,
B.value AS variable_character,
C.value AS text,
D.value AS integer
FROM customer_address_entity AS A
LEFT JOIN customer_address_entity_varchar AS B
ON B.entity_id = A.entity_id
LEFT JOIN customer_address_entity_text AS C
ON C.entity_id = A.entity_id
LEFT JOIN customer_address_entity_int AS D
ON A.entity_id = D.entity_id
ORDER BY A.entity_id DESC
LIMIT 100";
Однако есть много значений, которые должны быть присоединены к объекту в таблице А, и сейчас все они создают свой собственный вложенный массив на основе нового стоимость.
0 =>
array (size=4)
'entity_id' => string '597424' (length=6)
'variable_character' => string 'Dave' (length=4)
'text' => string '45 Haven Rd' (length=11)
'intiger' => string '43' (length=2)
1 =>
array (size=4)
'entity_id' => string '597424' (length=6)
'variable_character' => null
'text' => string '45 Haven Rd' (length=11)
'intiger' => string '43' (length=2)
2 =>
array (size=4)
'entity_id' => string '597424' (length=6)
'variable_character' => string 'Danielson' (length=9)
'text' => string '45 Haven Rd' (length=11)
'integer' => string '43' (length=2)
3 => etc
...
Im думая, что это происходит из-за того же имя ключа пытается соединить, и поэтому я хотел бы использовать что-то более динамичное, такие как другое значение, например, как значение B.attribute_type_id. где я мог бы получить массив выглядеть
array (size=7)
'entity_id' => string '597424' (length=6)
'1' => null
'2' => 'Dave'
'3' => 'Danielson'
'4' => '45 Haven Road'
'text' => string '45 Haven Rd' (length=11)
'intiger' => string '43' (length=2)
Или еще лучше: название для атрибутов жить в другой таблице под названием eav_attribute и что действительно было бы идеально было бы что-то вдоль линий
$query = "SELECT
A.entity_id,
B.value AS (SELECT attribute_code FROM eav_attribute WHERE attribute_id = B.attribute_id),
C.value AS text,
...
Возможно ли это? Или я об этом неправильно?