Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6241327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:44:54+00:00 2026-05-24T11:44:54+00:00

i have 2 tables members and comments.. i successfully joing them to. so now,

  • 0

i have 2 tables members and comments.. i successfully joing them to. so now, i can get an collection of all entries for any user. but i need to create anothewr table called ‘followers’ , where each user can follow each. therefore, now, i want to be able to get all comments from 1 user also the comments for the users he is following too. but dont know what way to approach to complete this relationship with this new table.

users entity:

namespace Entities\Members;

/**
 * @Entity(repositoryClass="\Entities\Member\MembersRepository")
 * @Table(name="Members")
 * @HasLifecycleCallbacks
 */
class Members extends \Entities\AbstractEntity
{
    /**
     * @Id @Column(name="id", type="bigint",length=15)
     * @GeneratedValue(strategy="AUTO")
     */
    protected $id;
    /** @Column(name="userid", type="bigint", length=26, nullable=true) */
    protected $userid;
    /** @Column(name="fname", type="string", length=255,nullable=true) */
    protected $fname;
    /** @OneToMany(targetEntity="\Entities\Users\Wall", mappedBy="entry", cascade={"persist"}) */
    protected $commententries;

    public function __construct()
    {
        $this->commententries = new \Doctrine\Common\Collections\ArrayCollection();
    }
}

comments entity:

 namespace Entities\Members;

/**
 * @Entity(repositoryClass="\Entities\Member\CommentsRepository")
 * @Table(name="comments")
 * @HasLifecycleCallbacks
 */
class Comments extends \Entities\AbstractEntity
{
    /**
     * @Id @Column(name="id", type="bigint",length=15)
     * @GeneratedValue(strategy="AUTO")
     */
    protected $id;
    /** @Column(name="userid", type="bigint", length=26, nullable=true) */

    /**
     * @ManyToOne(targetEntity="\Entities\Member\Member", cascade={"persist"})
     * @JoinColumn(name="userid", referencedColumnName="id")
     */
    protected $entry;

}

this works, i can get all comments from users via:

$this->repo->findByUserid(3);  (userid = 3)

however, how can i add a ‘following’ table (just like twitter). where one can follow other, and therefore, i would be able to not only, see user id-3 comments but other comments from other user he is following?

table called: followers:

  namespace Entities\Members;

/**
 * @Entity(repositoryClass="\Entities\Member\FollowersRepository")
 * @Table(name="followers")
 * @HasLifecycleCallbacks
 */
class Followers extends \Entities\AbstractEntity
{
    /**
     * @Id @Column(name="id", type="bigint",length=15)
     * @GeneratedValue(strategy="AUTO")
     */
    protected $id;
    /** @Column(name="userid", type="bigint", length=26, nullable=true) */

    protected ???;

    /**
     * @Many  ???
     * @JoinColumn(   ???
     */
    protected $???;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:44:55+00:00Added an answer on May 24, 2026 at 11:44 am

    Probably the best way to do this is to create a relationship from Followers to Members.

    Then create a EntityRepository for the Comments Entity in which you’ll create a function like: getCommentsByUserIdIncludingFollowers($userId) in which you create a DQL query that returns the correct information/comments you need.

    This would be the way I’d suggest.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have five tables in my database. Members, items, comments, votes and countries. I
I have 2 tables members ======= id f_name // get these values. l_name email
I have 2 tables, CLIENTS and MEMBERS . We are trying to get the
ok, here we go... I have 3 tables: posts, comments and members, i need
The case: I have 2 tables, 'contracts' and 'members' tied with contract.id = members.cid.
Possible Duplicate: MySQL delete row from multiple tables I have 5 tables: members member_videos
I have three tables: Table 1 - Members Id Name 1 Member1 2 Member2
I have two tables: members ( userid int primary key ) login_history ( userid
Assume that I have 2 tables : members and orders (Mysql) Members : id
I am not sure on how to do this. I have three tables members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.