I would use a field in a query but i receive this error: [Semantical Error] line 0, col 78 near 'resource_id =': Error: Class Dt\TagBundle\Entity\Tagging has no field or association named resource_id
This is my entity Tagging:
<?php
namespace Dt\TagBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
use FPN\TagBundle\Entity\Tagging as BaseTagging;
/**
* Dt\TagBundle\Entity\Tagging
*
* @ORM\Table(uniqueConstraints={@UniqueConstraint(name="tagging_idx", columns={"tag_id", "resource_type", "resource_id"})})
* @ORM\Entity
*/
class Tagging extends BaseTagging
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Dt\TagBundle\Entity\Tag")
* @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
**/
protected $tag;
}
The table on my db is: Tagging(id, tag_id, resource_type, resource_id) where tag_id correspond at the id of the table: Tag(id,name) and resource_id correspond at the User table User(id, name , surname, ...)
This is my search query:
$query = $em->createQueryBuilder()
->select('uu')
->from('DtEcBundle:User', 'uu')
->innerJoin("DtTagBundle:Tag","tg", "WITH", "tg.id = tig.tag")
->innerJoin("DtTagBundle:Tagging","tig", "WITH", "tig.resource_id = uu.id")
->innerJoin("DtTagBundle:Tag","tg", "WITH", "tg.id = tig.tag")
->where("uu.surname LIKE :search OR uu.name LIKE :search OR uu.profession LIKE :search OR tg.name LIKE :search")
->setParameter("search",$search.'%')
->getQuery();
How can i do to define resource_id??? Thanks