How do I perform queries in an entity?
namespace EntitiesMembers;
/**
* @Entity(repositoryClass="EntitiesMemberMembersRepository")
* @Table(name="Members")
* @HasLifecycleCallbacks
*/
class Members extends EntitiesAbstractEntity
{
/**
* @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="EntitiesUsersWall", mappedBy="entry", cascade={"persist"})
*/
protected $commententries;
public function __construct()
{
$this->commententries = new DoctrineCommonCollectionsArrayCollection();
}
}
Example I would like to have a function inside this entity called: filter()
and I want to be able to filter the commententries
collection. It should return a collection with a certain condition such id=1
. Basically it should be filtering the data received from the join query.
So something like this:
$this->commententries->findBy(array('id' => 1));
But obviously this does not work.
See Question&Answers more detail:os