I have three tables which look like this (simplified)
"plants" Table
ID (PK, AI) | botanicalName | quickCode
1 | Monstera adansonii | 1234567
2 | Aloe Vera | 1233456
"commonNames" Table
ID (PK, AI) | plantsID | commonName
1 | 1 | Swiss Cheese Vine
2 | 2 | Cape Fern
3 | 1 | Hurricane Plant
"images" Table
ID (PK, AI) | plantsID | fileName
1 | 1 | monstera_adansonii.jpg
2 | 2 | capefern.jpg
3 | 2 | capefern2.jpg
In "commonNames" and "images" tables the "plantsID" columns are references to the ID in "plants" table.
How could I write my MySQL Select and php to format a result like this:
array (
id => 1, //plants.id
botanicalName => Monstera adansonii, //plants.botanicalName
commonNames => array ( 0 => Swiss Cheese Vine, 1 => Hurricane Plant ), //commonNames.commonName (array)
fileName => array ( 0 => monstera_adansonii.jpg ) //images.fileName (array),
)