symfony - 'Error: Invalid PathExpression. Must be a StateFieldPathExpression' Error in doctrine -


i'm trying join 2 tables , take column value doctrine query builder.

this code

public function getlatestproduct($amount) {         $em = $this->container->get('doctrine.orm.entity_manager');          $qb = $em->createquerybuilder();          $qb->select('p.id, p.category, p.producttitle, p.price, p.description, pi.imgurl')                 ->from('eagleshopbundle:products', 'p')                 ->leftjoin('eagleshopbundle:prouctimage', 'pi', \doctrine\orm\query\expr\join::with, 'pi.productid = p.id')                 ->orderby('p.id', 'desc')                 ->groupby('p.id')                 ->setmaxresults($amount);          return $qb->getquery()->getresult();     } 

this call it

public function indexaction() {         $latest = $this->getlatestproduct(8);         $isfeatured = $this->getfeaturedproduct(8);          return $this->render("eagleshopbundle:global:home.html.twig", array(                     'image_path' => '/bundles/eagleshop/images/',                     'latest_products' => $latest,                     'isfeatured' => $isfeatured         ));     } 

but when try call method i'm having issue,

[semantical error] line 0, col 15 near 'category, p.producttitle,': error: invalid pathexpression. must statefieldpathexpression.

i think code related issue,

$qb->select('p.id, p.category, p.producttitle, p.price, p.description, pi.imgurl')

this product entity

<?php  namespace eagle\shopbundle\entity;  use doctrine\orm\mapping orm;  /**  * products  *  * @orm\table(name="products", indexes={@orm\index(name="category", columns={"category"})})  * @orm\entity  */ class products {     /**      * @var string      *      * @orm\column(name="product_title", type="string", length=400, nullable=false)      */     private $producttitle;      /**      * @var string      *      * @orm\column(name="description", type="string", length=400, nullable=false)      */     private $description;      /**      * @var float      *      * @orm\column(name="price", type="float", precision=10, scale=0, nullable=false)      */     private $price;      /**      * @var integer      *      * @orm\column(name="store_id", type="integer", nullable=false)      */     private $storeid;      /**      * @var integer      *      * @orm\column(name="status", type="integer", nullable=false)      */     private $status;      /**      * @var integer      *      * @orm\column(name="stock", type="integer", nullable=false)      */     private $stock;      /**      * @var integer      *      * @orm\column(name="isfeatured", type="integer", nullable=false)      */     private $isfeatured;      /**      * @var \datetime      *      * @orm\column(name="created_at", type="datetime", nullable=false)      */     private $createdat;      /**      * @var \datetime      *      * @orm\column(name="updated_at", type="datetime", nullable=false)      */     private $updatedat;      /**      * @var integer      *      * @orm\column(name="online", type="integer", nullable=false)      */     private $online;      /**      * @var integer      *      * @orm\column(name="id", type="integer")      * @orm\id      * @orm\generatedvalue(strategy="identity")      */     private $id;      /**      * @var \eagle\shopbundle\entity\productcategory      *      * @orm\manytoone(targetentity="eagle\shopbundle\entity\productcategory")      * @orm\joincolumns({      *   @orm\joincolumn(name="category", referencedcolumnname="id")      * })      */     private $category;        /**      * set producttitle      *      * @param string $producttitle      * @return products      */     public function setproducttitle($producttitle)     {         $this->producttitle = $producttitle;          return $this;     }      /**      * producttitle      *      * @return string       */     public function getproducttitle()     {         return $this->producttitle;     }      /**      * set description      *      * @param string $description      * @return products      */     public function setdescription($description)     {         $this->description = $description;          return $this;     }      /**      * description      *      * @return string       */     public function getdescription()     {         return $this->description;     }      /**      * set price      *      * @param float $price      * @return products      */     public function setprice($price)     {         $this->price = $price;          return $this;     }      /**      * price      *      * @return float       */     public function getprice()     {         return $this->price;     }      /**      * set storeid      *      * @param integer $storeid      * @return products      */     public function setstoreid($storeid)     {         $this->storeid = $storeid;          return $this;     }      /**      * storeid      *      * @return integer       */     public function getstoreid()     {         return $this->storeid;     }      /**      * set status      *      * @param integer $status      * @return products      */     public function setstatus($status)     {         $this->status = $status;          return $this;     }      /**      * status      *      * @return integer       */     public function getstatus()     {         return $this->status;     }      /**      * set stock      *      * @param integer $stock      * @return products      */     public function setstock($stock)     {         $this->stock = $stock;          return $this;     }      /**      * stock      *      * @return integer       */     public function getstock()     {         return $this->stock;     }      /**      * set isfeatured      *      * @param integer $isfeatured      * @return products      */     public function setisfeatured($isfeatured)     {         $this->isfeatured = $isfeatured;          return $this;     }      /**      * isfeatured      *      * @return integer       */     public function getisfeatured()     {         return $this->isfeatured;     }      /**      * set createdat      *      * @param \datetime $createdat      * @return products      */     public function setcreatedat($createdat)     {         $this->createdat = $createdat;          return $this;     }      /**      * createdat      *      * @return \datetime       */     public function getcreatedat()     {         return $this->createdat;     }      /**      * set updatedat      *      * @param \datetime $updatedat      * @return products      */     public function setupdatedat($updatedat)     {         $this->updatedat = $updatedat;          return $this;     }      /**      * updatedat      *      * @return \datetime       */     public function getupdatedat()     {         return $this->updatedat;     }      /**      * set online      *      * @param integer $online      * @return products      */     public function setonline($online)     {         $this->online = $online;          return $this;     }      /**      * online      *      * @return integer       */     public function getonline()     {         return $this->online;     }      /**      * id      *      * @return integer       */     public function getid()     {         return $this->id;     }      /**      * set category      *      * @param \eagle\shopbundle\entity\productcategory $category      * @return products      */     public function setcategory(\eagle\shopbundle\entity\productcategory $category = null)     {         $this->category = $category;          return $this;     }      /**      * category      *      * @return \eagle\shopbundle\entity\productcategory       */     public function getcategory()     {         return $this->category;     } } 


Comments