#php #symfony #doctrine-orm #symfony-2.3 #dql
#php #symfony #доктрина-orm #symfony-2.3 #dql
Вопрос:
Пакеты: WebCanyonExpenseBundle и WebCanyonCarBundle
Объекты:
- ExpenseBundle: Расход
- ExpenseBundle:ExpenseType
- CarBundle: Car
Проблема в том, что у каждого автомобиля может быть много расходов, и у каждого расхода есть тип
Ниже приведены определенные объекты:
Expense.php
namespace WebCanyonExpenseBundleEntity;
use DoctrineORMMapping as ORM;
/**
* Expense
*
* @ORMTable()
* @ORMEntity(repositoryClass="WebCanyonExpenseBundleEntityExpenseRepository")
*/
class Expense
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var integer
*
* @ORMColumn(name="car_id", type="integer")
*/
private $carId;
/**
* @var integer
*
* @ORMColumn(name="currency", type="integer")
*/
private $currency;
/**
* @var string
*
* @ORMColumn(name="title", type="string", length=100)
*/
private $title;
/**
* @var string
*
* @ORMColumn(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var integer
*
* @ORMColumn(name="type", type="integer")
*/
private $type;
/**
* @var string
*
* @ORMColumn(name="price", type="decimal", precision=6, scale=2)
*/
private $price;
/**
* @var integer
*
* @ORMColumn(name="status", type="integer")
*/
private $status;
/**
* @var DateTime
*
* @ORMColumn(name="timestamp", type="datetime")
*/
private $timestamp;
/*
* @var ArrayCollection
* @ORMManyToOne(targetEntity="WebCanyonCarBundleEntityCar", inversedBy="insurance")
* @ORMJoinColumn(name="car_id", referencedColumnName="id")
*/
private $car;
/*
* @var ArrayCollection
* @ORMManyToOne(targetEntity="ExpenseType, inversedBy="expense")
* @ORMJoinColumn(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 WebCanyonExpenseBundleEntity;
use DoctrineORMMapping as ORM;
use DoctrineCommonCollectionsArrayCollection;
/**
* ExpenseType
*
* @ORMTable()
* @ORMEntity(repositoryClass="WebCanyonExpenseBundleEntityExpenseTypeRepository")
*/
class ExpenseType
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORMColumn(name="name", type="string", length=100)
*/
private $name;
/**
* @var string
*
* @ORMColumn(name="description", type="string", length=255)
*/
private $description;
/**
* @var DateTime
*
* @ORMColumn(name="timestamp", type="datetime")
*/
private $timestamp;
/*
* @var ArrayCollection
* @ORMOneToMany(targetEntity="Expense", mappedBy="$etype")
* @ORMJoinColumn(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 WebCanyonCarBundleEntity;
use DoctrineORMMapping as ORM;
use DoctrineCommonCollectionsArrayCollection;
/**
* Car
*
* @ORMTable()
* @ORMEntity(repositoryClass="WebCanyonCarBundleEntityCarRepository")
*/
class Car
{
/**
* @var integer
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORMColumn(name="brand", type="string", length=100)
*/
private $brand;
/**
* @var string
*
* @ORMColumn(name="model", type="string", length=100)
*/
private $model;
/**
* @var string
*
* @ORMColumn(name="plate", type="string", length=25)
*/
private $plate;
/**
* @var string
*
* @ORMColumn(name="serial", type="string", length=17)
*/
private $serial;
/**
* @var string
*
* @ORMColumn(name="color", type="string", length=20, nullable=true)
*/
private $color;
/**
* @var integer
*
* @ORMColumn(name="fuel", type="integer")
*/
private $fuel;
/**
* @var DateTime
*
* @ORMColumn(name="fdate", type="date")
*/
private $fdate;
/**
* @var DateTime
*
* @ORMColumn(name="adate", type="date")
*/
private $adate;
/**
* @var integer
*
* @ORMColumn(name="status", type="integer")
*/
private $status;
/**
* @var DateTime
*
* @ORMColumn(name="modifdate", type="datetime")
*/
private $modifdate;
/*
*@var ArrayCollection
*@ORMOneToMany(targetEntity="WebCanyonInsuranceBundleEntityInsurance", 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 WebCanyonExpenseBundleEntity;
use DoctrineORMEntityRepository;
/**
* 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 »
И это весь журнал:
INFO - Matched route "web_canyon_expense_homepage" (parameters: "_controller": "WebCanyonExpenseBundleControllerDefaultController::indexAction", "locale": "ro", "_route": "web_canyon_expense_homepage")
...
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerDebugHandlersListener::configure".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerProfilerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyBundleFrameworkBundleEventListenerSessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerFragmentListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerRouterListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerLocaleListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentSecurityHttpFirewall::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyBundleAsseticBundleEventListenerRequestListener::onKernelRequest".
DEBUG - Notified event "kernel.controller" to listener "SymfonyBundleFrameworkBundleDataCollectorRouterDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "AcmeDemoBundleEventListenerControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SymfonyComponentHttpKernelDataCollectorRequestDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerParamConverterListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerHttpCacheListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerSecurityListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerTemplateListener::onKernelController".
CRITICAL - Uncaught PHP Exception DoctrineORMQueryQueryException: "[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 "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerErrorsLoggerListener::injectLogger".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerDebugHandlersListener::configure".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerProfilerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyBundleFrameworkBundleEventListenerSessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerFragmentListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerRouterListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerLocaleListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyComponentSecurityHttpFirewall::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "SymfonyBundleAsseticBundleEventListenerRequestListener::onKernelRequest".
DEBUG - Notified event "kernel.controller" to listener "SymfonyBundleFrameworkBundleDataCollectorRouterDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "AcmeDemoBundleEventListenerControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SymfonyComponentHttpKernelDataCollectorRequestDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerParamConverterListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerHttpCacheListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerSecurityListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "SensioBundleFrameworkExtraBundleEventListenerTemplateListener::onKernelController".
Трассировка стека Symfony
[1] DoctrineORMQueryQueryException: [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 DoctrineORMQueryQueryException::syntaxError('line 0, col 299: Error: Expected =, amp;<, amp;<=, amp;<amp;>, amp;>, amp;>=, !=, got amp;#039;caamp;#039;', object(QueryException))
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 448
at DoctrineORMQueryParser->syntaxError('=, amp;<, amp;<=, amp;<amp;>, amp;>, amp;>=, !=')
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 3233
at DoctrineORMQueryParser->ComparisonOperator()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2974
at DoctrineORMQueryParser->ComparisonExpression()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2501
at DoctrineORMQueryParser->SimpleConditionalExpression()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2384
at DoctrineORMQueryParser->ConditionalPrimary()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2360
at DoctrineORMQueryParser->ConditionalFactor()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2328
at DoctrineORMQueryParser->ConditionalTerm()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2303
at DoctrineORMQueryParser->ConditionalExpression()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1643
at DoctrineORMQueryParser->Join()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1558
at DoctrineORMQueryParser->IdentificationVariableDeclaration()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1286
at DoctrineORMQueryParser->FromClause()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 874
at DoctrineORMQueryParser->SelectStatement()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 843
at DoctrineORMQueryParser->QueryLanguage()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 268
at DoctrineORMQueryParser->getAST()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 351
at DoctrineORMQueryParser->parse()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 255
at DoctrineORMQuery->_parse()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 267
at DoctrineORMQuery->_doExecute()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 794
at DoctrineORMAbstractQuery->execute(null, '2')
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 586
at DoctrineORMAbstractQuery->getArrayResult()
in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Entity/ExpenseRepository.php line 20
at WebCanyonExpenseBundleEntityExpenseRepository->findAllComplete()
in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Controller/DefaultController.php line 16
at WebCanyonExpenseBundleControllerDefaultController->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 SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), '1')
in /home/symfony/www/fleet/var/bootstrap.php.cache line 2909
at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), '1', true)
in /home/symfony/www/fleet/var/bootstrap.php.cache line 3058
at SymfonyComponentHttpKernelDependencyInjectionContainerAwareHttpKernel->handle(object(Request), '1', true)
in /home/symfony/www/fleet/var/bootstrap.php.cache line 2308
at SymfonyComponentHttpKernelKernel->handle(object(Request))
in /home/symfony/www/fleet/web/app_dev.php line 28
[2] DoctrineORMQueryQueryException: 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 DoctrineORMQueryQueryException::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 DoctrineORMQueryParser->syntaxError('=, amp;<, amp;<=, amp;<amp;>, amp;>, amp;>=, !=')
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 3233
at DoctrineORMQueryParser->ComparisonOperator()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2974
at DoctrineORMQueryParser->ComparisonExpression()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2501
at DoctrineORMQueryParser->SimpleConditionalExpression()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2384
at DoctrineORMQueryParser->ConditionalPrimary()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2360
at DoctrineORMQueryParser->ConditionalFactor()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2328
at DoctrineORMQueryParser->ConditionalTerm()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 2303
at DoctrineORMQueryParser->ConditionalExpression()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1643
at DoctrineORMQueryParser->Join()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1558
at DoctrineORMQueryParser->IdentificationVariableDeclaration()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 1286
at DoctrineORMQueryParser->FromClause()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 874
at DoctrineORMQueryParser->SelectStatement()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 843
at DoctrineORMQueryParser->QueryLanguage()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 268
at DoctrineORMQueryParser->getAST()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php line 351
at DoctrineORMQueryParser->parse()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 255
at DoctrineORMQuery->_parse()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 267
at DoctrineORMQuery->_doExecute()
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 794
at DoctrineORMAbstractQuery->execute(null, '2')
in /home/symfony/www/fleet/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 586
at DoctrineORMAbstractQuery->getArrayResult()
in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Entity/ExpenseRepository.php line 20
at WebCanyonExpenseBundleEntityExpenseRepository->findAllComplete()
in /home/symfony/www/fleet/src/WebCanyon/ExpenseBundle/Controller/DefaultController.php line 16
at WebCanyonExpenseBundleControllerDefaultController->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 SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), '1')
in /home/symfony/www/fleet/var/bootstrap.php.cache line 2909
at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), '1', true)
in /home/symfony/www/fleet/var/bootstrap.php.cache line 3058
at SymfonyComponentHttpKernelDependencyInjectionContainerAwareHttpKernel->handle(object(Request), '1', true)
in /home/symfony/www/fleet/var/bootstrap.php.cache line 2308
at SymfonyComponentHttpKernelKernel->handle(object(Request))
in /home/symfony/www/fleet/web/app_dev.php line 28
Комментарии:
1. Что
WITH
в вашем запросе DQL? Вы не можете использоватьWHERE
? Кроме того, в вашихJOIN
заявлениях должно использоватьсяON
выражение для указания вашего условия объединения.2. Согласен, вы должны использовать
JOIN... ON...
.
Ответ №1:
Это был правильный 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();