私はポストモデル(MySQLのテーブルを)持っている、との構造のようなものです:CakePHPサブクエスト、どのように?
id, parent, user_id, title, desc, created, modified
会話の単一のスレッドがpost.parentが元にpost_idと一致した後続のすべての記事に続いて、ポスト、から構成されています。
サンプルuser_32とuser_40間の会話:内部クエリに続いて、私は単純に外部クエリを行うプレーンなPHPで
110, 0, 32, thread_title, sample_description_here, created_time, modified_time
121, 110, 40, comment_title, sample_comment_here, created_time, modified_time
130, 110, 32, comment_title, sample_comment_here, created_time, modified_time
140, 110, 32, comment_title, sample_comment_here, created_time, modified_time
166, 110, 40, comment_title, sample_comment_here, created_time, modified_time
290, 110, 32, comment_title, sample_comment_here, created_time, modified_time
、その後は画面に会話をエコーが、どのようにあなたは、CakePHPでこれを実現します??
質問:私は(上記参照)post_id_110、post.parentの== 110は、CREATED_TIMEのDESC順後続のすべての記事が続いからなる単会話を表示するには、CakePHPの中にクエリを作成するにはどうすればよい
。 ??ポストモデルで
クールで、どのように私はビューでそれを描くのですか?私は現在foreachループを持っていますが、私は上記の変更を行ってから働きません。ありがとう –
ちょうどその結果の配列を見るためにfind()の出力を表示し、それをループすることができます。 –