の内側に、私は3つのテーブルを持って、選択PHPのmysqlの、配列結果配列結果
tbl_photo tbl_photo_comments tbl_photo_likers
___________ ____________ _____________
| photo_id | | comment_id | | like_id |
| photo_url | | photo_id FK| | user_id FK |
| user_id FK| | user_id FK | | photo_id FK |
| comment |
私の目標は、それぞれのコメントデータとlikersデータとともにtbl_photoから写真データを取得することです。私は
oneResultArray =
{
photo_url = "www.url.com/photo.png";
photoID = 1;
user_id = 2
commentData = (
{
comment = "comment 1";
userid = 1
},
{
comment = "comment 2";
userid = 2
},
{
comment = "comment 3";
userid = 3});
likersData = (
{
userid = 2;
username = liker1;
},
{
userid = 3;
username = liker2;
});
},
{
photo_url = "www.url.com/photo.png";
photoID = 1;
user_id = 2
commentData = (
{
comment = "comment 1";
userid = 1
},
{
comment = "comment 2";
userid = 2
},
{
comment = "comment 3";
userid = 3});
likersData = (
{
userid = 2;
username = liker1;
},
{
userid = 3;
username = liker2;
});
}
私の質問があり、そのデータ上の要素として2つの以上のアレイを持っているONE結果配列を持っているでどこ以下のように私はしたい配列の構造があり、それは、MySQL上で1つのクエリを使用して、これを達成することは可能ですか?もしそうでなければ、これを行う他の方法はありますか?君たちありがとう!
はい、これが最適です。 – deed02392
こんにちは!ありがとう!大きな助け男! – janusbalatbat