0

質問が悪い場合は、最初に申し訳ありませんが、私の英語はあまり上手ではありません。

次のクエリがあります

SELECT 
    * 
FROM 
    `stream_post` 
        LEFT JOIN `stream_comment` 
            ON (`stream_post`.`stream_id` = `stream_comment`.`comment_stream_id`) 
        JOIN `users_metadata` 
            ON (`stream_post`.`user_id` = `users_metadata`.`user_id`) 
ORDER BY 
    `stream_id` DESC 
LIMIT 10

そして、問題は実際には、これらを同じページのコメントに使用したいということです

だから、それはこのようになります

parrent post 1
   children comment 1
   children comment 1

parrent post 2
   children2 comment 1
   children2 comment 1

そして、投稿ID(ストリームIDとは)をコメントテーブルにも保存して、それらに参加します。

しかし、結果を取得すると、次のようになります

Array
(
    [stream_id] => 1
    [user_id] => 1
    [stream_text] => dasdadada
    [date] => 1346400535
    [comment_id] => 1
    [comment_stream_id] => 1
    [comment_user_id] => 1
    [comment_text] => comment one
    [posted] => 0
    [full_name] => Henry Marg
    [gender] => 1
    [location] => Los Angeles
    [birth_year] => 2012
    [birth_month] => 1
    [birth_day] => 1
    [work_location] => Tesco
    [about] => Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
)


Array
(
    [stream_id] => 1
    [user_id] => 1
    [stream_text] => dasdadada
    [date] => 1346400535
    [comment_id] => 1
    [comment_stream_id] => 1
    [comment_user_id] => 1
    [comment_text] => comment 2
    [posted] => 0
    [full_name] => Henry Marg
    [gender] => 1
    [location] => Los Angeles
    [birth_year] => 2012
    [birth_month] => 1
    [birth_day] => 1
    [work_location] => Tesco
    [about] => Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
)

だから問題は、私がこれらに到達したとき、コメントが分離され、マージされたということですか?

だから私はこのように見えたい

rray
(
    [stream_id] => 1
    [user_id] => 1
    [stream_text] => dasdadada
    [date] => 1346400535
    [comment_id] => 1
    [comment_stream_id] => 1
    [comment_user_id] => 1
    [comment_text] => comment one
    [comment_text] => comment two
    [posted] => 0
    [full_name] => Henry Marg
    [gender] => 1
    [location] => Los Angeles
    [birth_year] => 2012
    [birth_month] => 1
    [birth_day] => 1
    [work_location] => Tesco
    [about] => Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
)

これを行う方法はありますか?誰かが私にヒントや例を教えてください。

本当に幸せだろう

4

2 に答える 2

0

配列内に同じ名前の 2 つのキーを含めることはできません。行ったときにキーの名前を変更する必要があります(おそらく最後に数字を追加します)

[comment_text_1] => comment one
[comment_text_2] => comment two

または、各要素をこのようなサブ要素の配列に変えることもできます-これはコードでより便利です

[comment_text] => array('comment one', 'comment two') 
于 2012-08-31T08:57:43.587 に答える
0

申し訳ありませんが、それがその方法です。すべてのデータを配列内に配置しない限り、foreach または for ステートメントを使用して、comment_text を順番に調べることができます。

于 2012-08-31T08:55:15.153 に答える