php - Create QueryBuilder for find for field ManuToMany -
i have entity devekoper , need find developer whohave password , have newreference,how tha dontnow:
/** * developers. * * @orm\table(name="developers") * @orm\entity(repositoryclass="artel\profilebundle\entity\developerrepository") */ class developer extends customuser { /** * @var int * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @var string * * @orm\column(name="password", type="string", length=80, nullable=true) */ protected $password; /** * @orm\manytomany(targetentity="artel\profilebundle\entity\codeuserreference", inversedby="alluser") */ protected $newreference;
and have entity codeuserreference in field codereference setreference user
class codeuserreference { /** * @var int * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @orm\manytoone(targetentity="artel\profilebundle\entity\developer", inversedby="newreference") */ protected $alluser; /** * @orm\column(type="string", length=255) */ protected $codereference; /** * @gedmo\timestampable(on="create") * @orm\column(type="datetime") */ protected $created_at;
and want find developer has reference of has not reference.i try:
public function getdeveloperswithrefernce() { $qb = $this->getentitymanager()->createquerybuilder('d'); $qb ->select('d') ->from('artelprofilebundle:developer', 'd') ->addselect('count(m.id) nmethods') ->join('d.newreference', 'm') ->groupby('d.id') ->orderby("nmethods", 'desc') ->getquery(); $query = $qb->getquery(); $results = $query->getresult(); return $results; }
i have error sqlstate[42s02]: base table or view not found: 1146 table 'artel.developer_codeuserreference' doesn't exist . need find developers has reference or whohas not reference.help
it saying table codeuserreference doesn't exist
so
->join(d.newreference, 'm')
is not going work.
can please show header of codeuserreference class?
have done migrations add table database?
check if command create file difference: doctrine:migrations:diff
public function getdeveloperswithrefernce() { $qb = $this->getentitymanager()->createquerybuilder('d'); $qb ->select('d') ->from('artelprofilebundle:developer', 'd') ->leftjoin('d.newreference', 'm') ->where('m.codereference null') ->andwhere('d.password null') ->getquery(); $query = $qb->getquery(); $results = $query->getresult(); return $results; }
Comments
Post a Comment