Cakephp - 查找线程
我有一个推文表,用于存储推文及其回复,例如此
推文(id,parent_id,tweet_message,time)
,其中如果是推文,则parent_id是自ID,如果是回复,则是父ID。如何进行查找以提取 id =parent_id 的推
文示例:
tweet(1, 1, '我的名字是 Harsha', 'time')parent_id = id 因为它是一条推文而不是回复 tweet(2, 1, 'Hello Harsha', 'time') Parent_id = 1 告诉它对 id = 1 的推文的回复
i have a tweet table that stores tweets and its replies like this
tweet(id, parent_id, tweet_message, time)
where parent_id is a self id if its a tweet and is of parent id if its a reply. how to do a find to pull out tweets where id = parent_id
example:
tweet(1, 1, 'My name is Harsha', 'time') parent_id = id since its a tweet and not a reply
tweet(2, 1, 'Hello Harsha', 'time') parent_id = 1 which tells its a reply to the tweet with id = 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不使用树行为?
Yarek T 的建议可能会起作用,但仅适用于一个级别。
Why don't you use the Tree behaviour?
Probably this suggested from Yarek T will work but only for one level.
理论上这应该可行。查看 SQL 调试日志以了解它在出现任何错误时会执行什么操作
或者如果您正在查找特定的 ID,
则可以使用 MySQL
<>
not 运算符来搜索所有内容非根推文或
This should theoretically work. Look at the SQL Debug log to find out what it does if there are any errors
Or if you are looking for a specific ID you can do
you can use MySQL
<>
not operator to search for all nonroot tweetsor