Ich habe eine Mysql-Abfrage:Convert Ergebnis mysql query in verschachteltem PHP-Array
SELECT
`pcm`.`ContactMechanismId` AS `ContactMechanismId`,
`tel`.`AreaCode` AS `AreaCode`,
`tel`.`PhoneNbr` AS `PhoneNbr`,
`tel`.`Extension` AS `Extension`,
`cmt`.`ContactMechanismTypeName` AS `ContactMechanismTypeName`,
`c`.`DialingCode` AS `DialingCode`,
`rt`.`RoleTypeName` AS `RoleTypeName`,
`cmpt`.`ContactMechanismPurposeTypeName` AS `ContactMechanismPurposeTypeName`
FROM
`PartyContactMechanisms` AS `pcm`
INNER JOIN
`Telephones` AS `tel` ON `pcm`.`ContactMechanismId` = `tel`.`ContactMechanismId`
INNER JOIN
`ContactMechanisms` AS `cm` ON `cm`.`ContactMechanismId` = `pcm`.`ContactMechanismId`
INNER JOIN
`ContactMechanismTypes` AS `cmt` ON `cmt`.`ContactMechanismTypeId` = `cm`.`ContactMechanismTypeId`
INNER JOIN
`Countries` AS `c` ON `tel`.`GeoId` = `c`.`GeoId`
INNER JOIN
`PartyContactMechanismPurposes` AS `pcmp` ON `pcm`.`ContactMechanismId` = `pcmp`.`ContactMechanismId`
INNER JOIN
`RoleTypes` AS `rt` ON `rt`.`RoleTypeId` = `pcm`.`RoleTypeId`
INNER JOIN
`ContactMechanismPurposeTypes` AS `cmpt` ON `pcmp`.`PurposeTypeId` = `cmpt`.`PurposeTypeId`
Das Ergebnis, das ich von Mysql erhalten wird
+--------------------+----------+----------+-----------+--------------------------+-------------+---------------+---------------------------------+
| ContactMechanismId | AreaCode | PhoneNbr | Extension | ContactMechanismTypeName | DialingCode | RoleTypeName | ContactMechanismPurposeTypeName |
+--------------------+----------+----------+-----------+--------------------------+-------------+---------------+---------------------------------+
| 2 | 111 | 22222222 | 2222 | landline | 375 | customer | common phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | contractor | common phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | manufacturer | common phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | customer | primary phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | contractor | primary phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | manufacturer | primary phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | customer | secretary phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | contractor | secretary phone |
| 2 | 111 | 22222222 | 2222 | landline | 375 | manufacturer | secretary phone |
| 1 | 17 | 2905950 | | landline | 375 | customer | other phone |
+--------------------+----------+----------+-----------+--------------------------+-------------+---------------+---------------------------------+
ich brauche, ist das obige Ergebnis in den folgenden umwandeln Array:
[
[ContactMechanismId, AreaCode, PhoneNbr, Extension, ContactMechanismTypeName, DialingCode, RoleTypeName[], ContactMechanismPurposeTypeName[]
]
In dem Arrays RoleTypeName[]
und ContactMechanismPurposeTypeName[]
geht alles mögliche val ues für eine bestimmte ContactMechanismId
aus der entsprechenden Spalte des mysql-Ergebnisses.
Wie kann ich das tun?
post Ihren MySQL-Code hier –
bieten Sie Ihre Tabellenstruktur und Abfrage haben Sie – Alex
Uuh, ich werde es versuchen. Problem ist, dass es ein sehr vereinfachtes Modell von dem ist, was wirklich passiert ... :) –