我有一个桩模型(MySQL表),并且结构是一样的东西:CakePHP子查询,如何?
id, parent, user_id, title, desc, created, modified
谈话的单个线程由一个帖子,随后所有后续的帖子,其中post.parent原来POST_ID匹配。 user_32和user_40之间
样品对话:和
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
用纯PHP,我只是做了外部查询,然后由内查询,则呼应谈话到屏幕上,但你如何使用CakePHP实现这一目标??
问题:
如何构建CakePHP的查询,显示组成的单个对话(见上文)post_id_110,其次是所有后续帖里post.parent == 110,由CREATED_TIME降序排序。 ??
很酷,我该如何在视图中绘制?我目前有一个foreach循环,但它不起作用,因为我做了上述更改。谢谢 –
只是打印出该find()的输出来查看结果数组,并且可以循环查看结果数组。 –