duanhegn231318 2014-06-16 14:40
浏览 49
已采纳

Symfony doctrine从两个bundle中加入三个实体

Bundles are: WebCanyonExpenseBundle and WebCanyonCarBundle

Entities are:

  1. ExpenseBundle:Expense
  2. ExpenseBundle:ExpenseType
  3. CarBundle:Car

Problem is: each car can have many expense and each expense has a type

Below are the defined entities:

Expense.php

namespace WebCanyon\ExpenseBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Expense
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="WebCanyon\ExpenseBundle\Entity\ExpenseRepository")
 */
class Expense
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var integer
 *
 * @ORM\Column(name="car_id", type="integer")
 */
private $carId;

/**
 * @var integer
 *
 * @ORM\Column(name="currency", type="integer")
 */
private $currency;

/**
 * @var string
 *
 * @ORM\Column(name="title", type="string", length=100)
 */
private $title;

/**
 * @var string
 *
 * @ORM\Column(name="description", type="text", nullable=true)
 */
private $description;

/**
 * @var integer
 *
 * @ORM\Column(name="type", type="integer")
 */
private $type;

/**
 * @var string
 *
 * @ORM\Column(name="price", type="decimal", precision=6, scale=2)
 */
private $price;

/**
 * @var integer
 *
 * @ORM\Column(name="status", type="integer")
 */
private $status;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="timestamp", type="datetime")
 */
private $timestamp;

/*
 * @var ArrayCollection
 * @ORM\ManyToOne(targetEntity="WebCanyon\CarBundle\Entity\Car", inversedBy="insurance")
 * @ORM\JoinColumn(name="car_id", referencedColumnName="id")
 */
private $car;

/*
 * @var ArrayCollection
 * @ORM\ManyToOne(targetEntity="ExpenseType, inversedBy="expense")
 * @ORM\JoinColumn(name="type", referencedColumnName="id")
 */
private $etype;

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set carId
 *
 * @param integer $carId
 * @return Expense
 */
public function setCarId($carId)
{
    $this->carId = $carId;

    return $this;
}

/**
 * Get carId
 *
 * @return integer 
 */
public function getCarId()
{
    return $this->carId;
}

/**
 * Set currency
 *
 * @param integer $currency
 * @return Expense
 */
public function setCurrency($currency)
{
    $this->currency = $currency;

    return $this;
}

/**
 * Get currency
 *
 * @return integer 
 */
public function getCurrency()
{
    return $this->currency;
}

/**
 * Set title
 *
 * @param string $title
 * @return Expense
 */
public function setTitle($title)
{
    $this->title = $title;

    return $this;
}

/**
 * Get title
 *
 * @return string 
 */
public function getTitle()
{
    return $this->title;
}

/**
 * Set description
 *
 * @param string $description
 * @return Expense
 */
public function setDescription($description)
{
    $this->description = $description;

    return $this;
}

/**
 * Get description
 *
 * @return string 
 */
public function getDescription()
{
    return $this->description;
}

/**
 * Set type
 *
 * @param integer $type
 * @return Expense
 */
public function setType($type)
{
    $this->type = $type;

    return $this;
}

/**
 * Get type
 *
 * @return integer 
 */
public function getType()
{
    return $this->type;
}

/**
 * Set price
 *
 * @param string $price
 * @return Expense
 */
public function setPrice($price)
{
    $this->price = $price;

    return $this;
}

/**
 * Get price
 *
 * @return string 
 */
public function getPrice()
{
    return $this->price;
}

/**
 * Set status
 *
 * @param integer $status
 * @return Expense
 */
public function setStatus($status)
{
    $this->status = $status;

    return $this;
}

/**
 * Get status
 *
 * @return integer 
 */
public function getStatus()
{
    return $this->status;
}

/**
 * Set timestamp
 *
 * @param \DateTime $timestamp
 * @return Expense
 */
public function setTimestamp($timestamp)
{
    $this->timestamp = $timestamp;

    return $this;
}

/**
 * Get timestamp
 *
 * @return \DateTime 
 */
public function getTimestamp()
{
    return $this->timestamp;
}
}

ExpenseType.php

<?php

namespace WebCanyon\ExpenseBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * ExpenseType
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="WebCanyon\ExpenseBundle\Entity\ExpenseTypeRepository")
 */
class ExpenseType
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=100)
 */
private $name;

/**
 * @var string
 *
 * @ORM\Column(name="description", type="string", length=255)
 */
private $description;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="timestamp", type="datetime")
 */
private $timestamp;

/*
 * @var ArrayCollection
 * @ORM\OneToMany(targetEntity="Expense", mappedBy="$etype")
 * @ORM\JoinColumn(name="id", referencedColumnName="type")
 */
private $car;


/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set name
 *
 * @param string $name
 * @return ExpenseType
 */
public function setName($name)
{
    $this->name = $name;

    return $this;
}

/**
 * Get name
 *
 * @return string 
 */
public function getName()
{
    return $this->name;
}

/**
 * Set description
 *
 * @param string $description
 * @return ExpenseType
 */
public function setDescription($description)
{
    $this->description = $description;

    return $this;
}

/**
 * Get description
 *
 * @return string 
 */
public function getDescription()
{
    return $this->description;
}

/**
 * Set timestamp
 *
 * @param \DateTime $timestamp
 * @return ExpenseType
 */
public function setTimestamp($timestamp)
{
    $this->timestamp = $timestamp;

    return $this;
}

/**
 * Get timestamp
 *
 * @return \DateTime 
 */
public function getTimestamp()
{
    return $this->timestamp;
}
}

Car.php

<?php

 namespace WebCanyon\CarBundle\Entity;

 use Doctrine\ORM\Mapping as ORM;
 use Doctrine\Common\Collections\ArrayCollection;

 /**
 * Car
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="WebCanyon\CarBundle\Entity\CarRepository")
 */
class Car
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="brand", type="string", length=100)
 */
private $brand;

/**
 * @var string
 *
 * @ORM\Column(name="model", type="string", length=100)
 */
private $model;

/**
 * @var string
 *
 * @ORM\Column(name="plate", type="string", length=25)
 */
private $plate;

/**
 * @var string
 *
 * @ORM\Column(name="serial", type="string", length=17)
 */
private $serial;

/**
 * @var string
 *
 * @ORM\Column(name="color", type="string", length=20, nullable=true)
 */
private $color;

/**
 * @var integer
 *
 * @ORM\Column(name="fuel", type="integer")
 */
private $fuel;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="fdate", type="date")
 */
private $fdate;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="adate", type="date")
 */
private $adate;

/**
 * @var integer
 *
 * @ORM\Column(name="status", type="integer")
 */
private $status;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="modifdate", type="datetime")
 */
private $modifdate;

/*
 *@var ArrayCollection
 *@ORM\OneToMany(targetEntity="WebCanyon\InsuranceBundle\Entity\Insurance", mappedBy="car")
 */
private $insurance;

public function __construct(){
    $this->insurance = new ArrayCollection();
}

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set brand
 *
 * @param string $brand
 * @return Car
 */
public function setBrand($brand)
{
    $this->brand = $brand;

    return $this;
}

/**
 * Get brand
 *
 * @return string 
 */
public function getBrand()
{
    return $this->brand;
}

/**
 * Set model
 *
 * @param string $model
 * @return Car
 */
public function setModel($model)
{
    $this->model = $model;

    return $this;
}

/**
 * Get model
 *
 * @return string 
 */
public function getModel()
{
    return $this->model;
}

/**
 * Set plate
 *
 * @param string $plate
 * @return Car
 */
public function setPlate($plate)
{
    $this->plate = $plate;

    return $this;
}

/**
 * Get plate
 *
 * @return string 
 */
public function getPlate()
{
    return $this->plate;
}

/**
 * Set serial
 *
 * @param string $serial
 * @return Car
 */
public function setSerial($serial)
{
    $this->serial = $serial;

    return $this;
}

/**
 * Get serial
 *
 * @return string 
 */
public function getSerial()
{
    return $this->serial;
}

/**
 * Set color
 *
 * @param string $color
 * @return Car
 */
public function setColor($color)
{
    $this->color = $color;

    return $this;
}

/**
 * Get color
 *
 * @return string 
 */
public function getColor()
{
    return $this->color;
}

/**
 * Set fuel
 *
 * @param integer $fuel
 * @return Car
 */
public function setFuel($fuel)
{
    $this->fuel = $fuel;

    return $this;
}

/**
 * Get fuel
 *
 * @return integer 
 */
public function getFuel()
{
    return $this->fuel;
}

/**
 * Set fdate
 *
 * @param \DateTime $fdate
 * @return Car
 */
public function setFdate($fdate)
{
    $this->fdate = $fdate;

    return $this;
}

/**
 * Get fdate
 *
 * @return \DateTime 
 */
public function getFdate()
{
    return $this->fdate;
}

/**
 * Set adate
 *
 * @param \DateTime $adate
 * @return Car
 */
public function setAdate($adate)
{
    $this->adate = $adate;

    return $this;
}

/**
 * Get adate
 *
 * @return \DateTime 
 */
public function getAdate()
{
    return $this->adate;
}

/**
 * Set status
 *
 * @param integer $status
 * @return Car
 */
public function setStatus($status)
{
    $this->status = $status;

    return $this;
}

/**
 * Get status
 *
 * @return integer 
 */
public function getStatus()
{
    return $this->status;
}

/**
 * Set modifdate
 *
 * @param \DateTime $modifdate
 * @return Car
 */
public function setModifdate($modifdate)
{
    $this->modifdate = $modifdate;

    return $this;
}

/**
 * Get modifdate
 *
 * @return \DateTime 
 */
public function getModifdate()
{
    return $this->modifdate;
}
}

And I tried this to fetch joined data

<?php

namespace WebCanyon\ExpenseBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * ExpenseRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class ExpenseRepository extends EntityRepository
{
    function findAllComplete(){
       $em = $this->getEntityManager();
       return $em->createQuery("SELECT e.id, e.carId, e.title, e.description, eType.name, eType.description, e.price, e.status, e.timestamp, c.plate, c.brand, c.model
                                                FROM WebCanyonExpenseBundle:Expense e JOIN WebCanyonExpenseBundle:ExpenseType eType JOIN WebCanyonCarBundle:Car ca
                                                WITH e.type = eType.id AND e.carId = ca.id ")
                    ->getArrayResult();
   }
}

This is the response:

[Syntax Error] line 0, col 299: Error: Expected =, <, <=, <>, >, >=, !=, got 'ca'
500 Internal Server Error - QueryException
1 linked Exception: QueryException »

And this is the entire log:

INFO - Matched route "web_canyon_expense_homepage" (parameters: "_controller": "WebCanyon\ExpenseBundle\Controller\DefaultController::indexAction", "locale": "ro", "_route": "web_canyon_expense_homepage") 
...
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener::injectLogger". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Acme\DemoBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". 
CRITICAL - Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Syntax Error] line 0, col 299: Error: Expected =, <, <=, <>, >, >=, !=, got 'ca'" at /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 52 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener::injectLogger". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener::injectLogger". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ErrorsLoggerListener::injectLogger". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Acme\DemoBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". 

Symfony Stack Trace

 [1] Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 299: Error: Expected =, <, <=, <>, >, >=, !=, got 'ca'
at n/a
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 52

at Doctrine\ORM\Query\QueryException::syntaxError('line 0, col 299: Error: Expected =, &lt;, &lt;=, &lt;&gt;, &gt;, &gt;=, !=, got &#039;ca&#039;', object(QueryException))
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 448

at Doctrine\ORM\Query\Parser->syntaxError('=, &lt;, &lt;=, &lt;&gt;, &gt;, &gt;=, !=')
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 3233

at Doctrine\ORM\Query\Parser->ComparisonOperator()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2974

at Doctrine\ORM\Query\Parser->ComparisonExpression()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2501

at Doctrine\ORM\Query\Parser->SimpleConditionalExpression()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2384

at Doctrine\ORM\Query\Parser->ConditionalPrimary()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2360

at Doctrine\ORM\Query\Parser->ConditionalFactor()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2328

at Doctrine\ORM\Query\Parser->ConditionalTerm()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2303

at Doctrine\ORM\Query\Parser->ConditionalExpression()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1643

at Doctrine\ORM\Query\Parser->Join()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1558

at Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1286

at Doctrine\ORM\Query\Parser->FromClause()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 874

at Doctrine\ORM\Query\Parser->SelectStatement()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 843

at Doctrine\ORM\Query\Parser->QueryLanguage()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 268

at Doctrine\ORM\Query\Parser->getAST()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 351

at Doctrine\ORM\Query\Parser->parse()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 255

at Doctrine\ORM\Query->_parse()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 267

at Doctrine\ORM\Query->_doExecute()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 794

at Doctrine\ORM\AbstractQuery->execute(null, '2')
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 586

at Doctrine\ORM\AbstractQuery->getArrayResult()
    in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Entity/ExpenseRepository.php line 20

at WebCanyon\ExpenseBundle\Entity\ExpenseRepository->findAllComplete()
    in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Controller/DefaultController.php line 16

at WebCanyon\ExpenseBundle\Controller\DefaultController->indexAction()
    in  line 

at call_user_func_array(array(object(DefaultController), 'indexAction'), array())
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 2947

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 2909

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 3058

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 2308

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in /home/symfony/www/fleet/web/app_dev.php line 28

[2] Doctrine\ORM\Query\QueryException: SELECT e.id, e.carId, e.title, e.description, eType.name, eType.description, e.price, e.status, e.timestamp, c.plate, c.brand, c.model
                                                FROM WebCanyonExpenseBundle:Expense e JOIN WebCanyonExpenseBundle:ExpenseType eType JOIN WebCanyonCarBundle:Car ca
                                                WITH e.type = eType.id AND e.carId = ca.id 
at n/a
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 41

at Doctrine\ORM\Query\QueryException::dqlError('SELECT e.id, e.carId, e.title, e.description, eType.name, eType.description, e.price, e.status, e.timestamp, c.plate, c.brand, c.model
                                                FROM WebCanyonExpenseBundle:Expense e JOIN WebCanyonExpenseBundle:ExpenseType eType JOIN WebCanyonCarBundle:Car ca
                                                WITH e.type = eType.id AND e.carId = ca.id ')
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 448

at Doctrine\ORM\Query\Parser->syntaxError('=, &lt;, &lt;=, &lt;&gt;, &gt;, &gt;=, !=')
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 3233

at Doctrine\ORM\Query\Parser->ComparisonOperator()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2974

at Doctrine\ORM\Query\Parser->ComparisonExpression()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2501

at Doctrine\ORM\Query\Parser->SimpleConditionalExpression()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2384

at Doctrine\ORM\Query\Parser->ConditionalPrimary()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2360

at Doctrine\ORM\Query\Parser->ConditionalFactor()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2328

at Doctrine\ORM\Query\Parser->ConditionalTerm()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2303

at Doctrine\ORM\Query\Parser->ConditionalExpression()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1643

at Doctrine\ORM\Query\Parser->Join()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1558

at Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1286

at Doctrine\ORM\Query\Parser->FromClause()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 874

at Doctrine\ORM\Query\Parser->SelectStatement()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 843

at Doctrine\ORM\Query\Parser->QueryLanguage()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 268

at Doctrine\ORM\Query\Parser->getAST()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 351

at Doctrine\ORM\Query\Parser->parse()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 255

at Doctrine\ORM\Query->_parse()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 267

at Doctrine\ORM\Query->_doExecute()
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 794

at Doctrine\ORM\AbstractQuery->execute(null, '2')
    in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 586

at Doctrine\ORM\AbstractQuery->getArrayResult()
    in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Entity/ExpenseRepository.php line 20

at WebCanyon\ExpenseBundle\Entity\ExpenseRepository->findAllComplete()
    in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Controller/DefaultController.php line 16

at WebCanyon\ExpenseBundle\Controller\DefaultController->indexAction()
    in  line 

at call_user_func_array(array(object(DefaultController), 'indexAction'), array())
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 2947

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 2909

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 3058

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in /home/symfony/www/fleet/var/bootstrap.php.cache line 2308

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in /home/symfony/www/fleet/web/app_dev.php line 28
  • 写回答

1条回答 默认 最新

  • doujubeng2942 2014-06-17 07:51
    关注

    This was the right DQL

    $em = $this->getEntityManager();
        return $em->createQuery("SELECT e.id, e.carId, e.title, e.description, e.price, e.currency, e.status, e.timestamp, c.plate, c.brand, c.model, et.name, et.description
                                 FROM
                                     WebCanyonExpenseBundle:Expense e JOIN WebCanyonCarBundle:Car c WITH  e.carId = c.id
                                     JOIN WebCanyonExpenseBundle:ExpenseType et WITH  e.type = et.id 
                                                    ")
                        ->getArrayResult();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记