Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN'
Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN'
我正在使用原则为电子商务网站构建运输系统。为此,我已根据结账时的产品和地区数据获得合适的运输方式和价格。
我在 QueryBuilder 中使用以下代码:
$shippingPriceReccords
= $this->em->createQueryBuilder()
->select('price')
->from('OrderShippingPrice', 'price')
->innerJoin('OrderShippingMethod', 'method', 'price.fkOrderShippingMethod = method.id')
->innerJoin('OrderShippingMethodRegionMapping', 'map', 'map.fkOrderShippingMethod = method.id')
->where('price.fkProductType = :fkProductType')
->andwhere('price.fkBrand = :fkBrand')
->andwhere('map.fkRegion = :fkRegion')
->setParameters([
'fkProductType' => $fkProductType,
'fkBrand' => $fkBrand,
'fkRegion' => $regionID,
])
->getQuery()
->setFetchMode("OrderCart", "address", \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER)
->getResult();
但是这是失败的,并给我这个错误:
[Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN'
上述查询的 DQL:
SELECT price FROM OrderShippingPrice price INNER JOIN OrderShippingMethod method INNER JOIN OrderShippingMethodRegionMapping map WHERE price.fkProductType = :fkProductType AND price.fkBrand = :fkBrand AND map.fkRegion = :fkRegion
OrderShippingPrice 包含:
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OrderShippingPrice
*
* @ORM\Table(name="orderShippingPrice")
* @ORM\Entity
*/
class OrderShippingPrice
{
/**
*
* Normal string / int object data
*
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="fkOrderShippingMethod", type="integer", nullable=true)
*/
private $fkOrderShippingMethod = '0';
/**
* @var float
*
* @ORM\Column(name="price", type="float", precision=7, scale=2, nullable=false)
*/
private $price = '0.00';
/**
* @var int
*
* @ORM\Column(name="fkProductType", type="integer", nullable=true)
*/
private $fkProductType = '0';
/**
* @var int
*
* @ORM\Column(name="fkBrand", type="integer", nullable=true)
*/
private $fkBrand = '0';
/**
* @var string
*
* @ORM\Column(name="isExpeditable", type="string", length=16, nullable=false)
*/
private $isExpeditable = '0';
/**
* @var string
*
* @ORM\Column(name="expediteDescription", type="text", length=65535, nullable=false)
*/
private $expediteDescription = '';
/**
* @var string
*
* @ORM\Column(name="showLiftGateOption", type="string", length=16, nullable=false)
*/
private $showLiftGateOption = '0';
/**
* @var string
*
* @ORM\Column(name="showDestinationOption", type="string", length=16, nullable=false)
*/
private $showDestinationOption = '0';
/**
* @var string
*
* @ORM\Column(name="productNotAvailable", type="string", length=16, nullable=false)
*/
private $productNotAvailable = '0';
/**
*
* Relationship managment propperties
*
*/
/**
* Many OrderShippingPrices have One OrderShippingMethod.
* @ORM\ManyToOne(targetEntity="OrderShippingMethod", fetch="EAGER")
* @ORM\JoinColumn(name="fkOrderShippingMethod", referencedColumnName="id")
**/
private $orderShippingMethod;
/**
* Get orderOrderShippingMethod
*
* @return OrderShippingMethod
*/
public function getOrderShippingMethod()
{
return $this->orderShippingMethod;
}
/**
*
* Normal string / int getters and setters
*
*/
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set fkOrderShippingMethod
*
* @param string $fkOrderShippingMethod
*
* @return OrderCart
*/
public function setFkOrderShippingMethod($fkOrderShippingMethod)
{
$this->fkOrderShippingMethod = $fkOrderShippingMethod;
return $this;
}
/**
* Get fkOrderShippingMethod
*
* @return string
*/
public function getFkOrderShippingMethod()
{
return $this->fkOrderShippingMethod;
}
/**
* Set price
*
* @param string $price
*
* @return OrderCart
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return string
*/
public function getPrice()
{
return $this->price;
}
/**
* Set fkProductType
*
* @param string $fkProductType
*
* @return OrderCart
*/
public function setFkProductType($fkProductType)
{
$this->fkProductType = $fkProductType;
return $this;
}
/**
* Get fkProductType
*
* @return string
*/
public function getFkProductType()
{
return $this->fkProductType;
}
/**
* Set fkBrand
*
* @param string $fkBrand
*
* @return OrderCart
*/
public function setFkBrand($fkBrand)
{
$this->fkBrand = $fkBrand;
return $this;
}
/**
* Get fkBrand
*
* @return string
*/
public function getFkBrand()
{
return $this->fkBrand;
}
/**
* Set isExpeditable
*
* @param string $isExpeditable
*
* @return OrderCart
*/
public function setIsExpeditable($isExpeditable)
{
$this->isExpeditable = $isExpeditable;
return $this;
}
/**
* Get isExpeditable
*
* @return string
*/
public function getIsExpeditable()
{
return $this->isExpeditable;
}
/**
* Set expediteDescription
*
* @param string $expediteDescription
*
* @return OrderCart
*/
public function setExpediteDescription($expediteDescription)
{
$this->expediteDescription = $expediteDescription;
return $this;
}
/**
* Get expediteDescription
*
* @return string
*/
public function getExpediteDescription()
{
return $this->expediteDescription;
}
/**
* Set showLiftGateOption
*
* @param string $showLiftGateOption
*
* @return OrderCart
*/
public function setShowLiftGateOption($showLiftGateOption)
{
$this->showLiftGateOption = $showLiftGateOption;
return $this;
}
/**
* Get showLiftGateOption
*
* @return string
*/
public function getShowLiftGateOption()
{
return $this->showLiftGateOption;
}
/**
* Set showDestinationOption
*
* @param string $showDestinationOption
*
* @return OrderCart
*/
public function setShowDestinationOption($showDestinationOption)
{
$this->showDestinationOption = $showDestinationOption;
return $this;
}
/**
* Get showDestinationOption
*
* @return string
*/
public function getShowDestinationOption()
{
return $this->showDestinationOption;
}
/**
* Set productNotAvailable
*
* @param string $productNotAvailable
*
* @return OrderCart
*/
public function setProductNotAvailable($productNotAvailable)
{
$this->productNotAvailable = $productNotAvailable;
return $this;
}
/**
* Get productNotAvailable
*
* @return string
*/
public function getProductNotAvailable()
{
return $this->productNotAvailable;
}
}
OrderShippingMethod 包含:
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OrderShippingMethod
*
* @ORM\Table(name="orderShippingMethod")
* @ORM\Entity
*/
class OrderShippingMethod
{
/**
*
* Normal string / int object data
*
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="text", length=255, nullable=false)
*/
private $name = '';
/**
* @var string
*
* @ORM\Column(name="carrier", type="string", length=32, nullable=false)
*/
private $carrier = '';
/**
* @var string
*
* @ORM\Column(name="bvCode", type="string", length=32, nullable=false)
*/
private $bvCode = '';
/**
* @var string
*
* @ORM\Column(name="trackingUrl", type="string", length=255, nullable=true)
*/
private $trackingUrl = '';
/**
* @var int
*
* @ORM\Column(name="minimumLeadTime", type="integer", nullable=false)
*/
private $minimumLeadTime = '0';
/**
* @var int
*
* @ORM\Column(name="maximumLeadTime", type="integer", nullable=false)
*/
private $maximumLeadTime = '0';
/**
*
* Relationship managment propperties
*
*/
/**
* @ORM\OneToMany(targetEntity="OrderShippingMethodRegionMapping", mappedBy="orderShippingMethod", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EAGER")
* @var orderShippingMethodRegionMappings[]
**/
public $orderShippingMethodRegionMappings;
/**
* Constructor
*
* Create array for collection of orderShippingMethodRegionMappings
*/
public function __construct()
{
$this->orderShippingMethodRegionMappings = new ArrayCollection();
}
/**
* Get orderShippingMethodRegionMapping(s)
*
* @return array
*/
public function getOrderShippingMethodRegionMappings()
{
return $this->orderShippingMethodRegionMappings;
}
/**
*
* Normal string / int getters and setters
*
*/
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param int $name
*
* @return OrderCart
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return int
*/
public function getName()
{
return $this->name;
}
/**
* Set carrier
*
* @param string $carrier
*
* @return OrderCart
*/
public function setCarrier($carrier)
{
$this->carrier = $carrier;
return $this;
}
/**
* Get carrier
*
* @return string
*/
public function getCarrier()
{
return $this->carrier;
}
/**
* Set bvCode
*
* @param string $bvCode
*
* @return OrderCart
*/
public function setBvCode($bvCode)
{
$this->bvCode = $bvCode;
return $this;
}
/**
* Get bvCode
*
* @return string
*/
public function getBvCode()
{
return $this->bvCode;
}
/**
* Set trackingUrl
*
* @param string $trackingUrl
*
* @return OrderCart
*/
public function setTrackingUrl($trackingUrl)
{
$this->trackingUrl = $trackingUrl;
return $this;
}
/**
* Get trackingUrl
*
* @return string
*/
public function getTrackingUrl()
{
return $this->trackingUrl;
}
/**
* Set minimumLeadTime
*
* @param string $minimumLeadTime
*
* @return OrderCart
*/
public function setMinimumLeadTime($minimumLeadTime)
{
$this->minimumLeadTime = $minimumLeadTime;
return $this;
}
/**
* Get minimumLeadTime
*
* @return string
*/
public function getMinimumLeadTime()
{
return $this->minimumLeadTime;
}
/**
* Set maximumLeadTime
*
* @param string $maximumLeadTime
*
* @return OrderCart
*/
public function setMaximumLeadTime($maximumLeadTime)
{
$this->maximumLeadTime = $maximumLeadTime;
return $this;
}
/**
* Get maximumLeadTime
*
* @return string
*/
public function getMaximumLeadTime()
{
return $this->maximumLeadTime;
}
}
OrderShippingMethodRegionMapping 包含:
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OrderShippingMethodRegionMapping
*
* @ORM\Table(name="orderShippingMethodRegionMapping")
* @ORM\Entity
*/
class OrderShippingMethodRegionMapping
{
/**
*
* Normal string / int object data
*
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="fkOrderShippingMethod", type="integer")
*/
private $fkOrderShippingMethod = '0';
/**
* @var int
*
* @ORM\Column(name="fkOrderRegion", type="integer")
*/
private $fkOrderRegion = '0';
/**
*
* Relationship managment propperties
*
*/
/**
* Many OrderShippingPrices have One OrderShippingMethod.
* @ORM\ManyToOne(targetEntity="OrderShippingMethod", inversedBy="orderShippingMethodRegionMappings")
* @ORM\JoinColumn(name="fkOrderShippingMethod", referencedColumnName="id")
**/
private $orderShippingMethod;
/**
* Sets a new OrderShippingMethod and cleans the previous one if set
* @param OrderShippingMethod
*/
public function setOrderShippingMethod(OrderShippingMethod $orderShippingMethod)
{
$this->orderShippingMethod = $orderShippingMethod;
}
/**
* Get orderOrderShippingMethod
*
* @return OrderShippingMethod
*/
public function getOrderShippingMethod()
{
return $this->orderShippingMethod;
}
/**
*
* Normal string / int getters and setters
*
*/
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set fkOrderShippingMethod
*
* @param int $fkOrderShippingMethod
*
* @return OrderCart
*/
public function setFkOrderShippingMethod($fkOrderShippingMethod)
{
$this->fkOrderShippingMethod = $fkOrderShippingMethod;
return $this;
}
/**
* Get fkOrderShippingMethod
*
* @return int
*/
public function getFkOrderShippingMethod()
{
return $this->fkOrderShippingMethod;
}
/**
* Set fkOrderRegion
*
* @param int $fkOrderRegion
*
* @return OrderCart
*/
public function setFkOrderRegion($fkOrderRegion)
{
$this->fkOrderRegion = $fkOrderRegion;
return $this;
}
/**
* Get fkOrderRegion
*
* @return int
*/
public function getFkOrderRegion()
{
return $this->fkOrderRegion;
}
}
有人可以告诉我我做错了什么吗?感谢您的帮助。
您在 innerJoin
方法调用中缺少参数。你必须这样做:
$shippingPriceReccords
= $this->em->createQueryBuilder()
->select('price')
->from('OrderShippingPrice', 'price')
->innerJoin('OrderShippingMethod', 'method', 'WITH', 'price.fkOrderShippingMethod = method.id')
->innerJoin('OrderShippingMethodRegionMapping', 'map', 'WITH', 'map.fkOrderShippingMethod = method.id')
->where('price.fkProductType = :fkProductType')
->andwhere('price.fkBrand = :fkBrand')
->andwhere('map.fkRegion = :fkRegion')
->setParameters([
'fkProductType' => $fkProductType,
'fkBrand' => $fkBrand,
'fkRegion' => $regionID,
])
->getQuery()
->setFetchMode("OrderCart", "address", \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER)
->getResult();
见 documentation :
// Example - $qb->innerJoin('u.Group', 'g', Expr\Join::WITH, $qb->expr()->eq('u.status_id', '?1'))
// Example - $qb->innerJoin('u.Group', 'g', 'WITH', 'u.status = ?1')
// Example - $qb->innerJoin('u.Group', 'g', 'WITH', 'u.status = ?1', 'g.id')
public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null);
我正在使用原则为电子商务网站构建运输系统。为此,我已根据结账时的产品和地区数据获得合适的运输方式和价格。
我在 QueryBuilder 中使用以下代码:
$shippingPriceReccords
= $this->em->createQueryBuilder()
->select('price')
->from('OrderShippingPrice', 'price')
->innerJoin('OrderShippingMethod', 'method', 'price.fkOrderShippingMethod = method.id')
->innerJoin('OrderShippingMethodRegionMapping', 'map', 'map.fkOrderShippingMethod = method.id')
->where('price.fkProductType = :fkProductType')
->andwhere('price.fkBrand = :fkBrand')
->andwhere('map.fkRegion = :fkRegion')
->setParameters([
'fkProductType' => $fkProductType,
'fkBrand' => $fkBrand,
'fkRegion' => $regionID,
])
->getQuery()
->setFetchMode("OrderCart", "address", \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER)
->getResult();
但是这是失败的,并给我这个错误:
[Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN'
上述查询的 DQL:
SELECT price FROM OrderShippingPrice price INNER JOIN OrderShippingMethod method INNER JOIN OrderShippingMethodRegionMapping map WHERE price.fkProductType = :fkProductType AND price.fkBrand = :fkBrand AND map.fkRegion = :fkRegion
OrderShippingPrice 包含:
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OrderShippingPrice
*
* @ORM\Table(name="orderShippingPrice")
* @ORM\Entity
*/
class OrderShippingPrice
{
/**
*
* Normal string / int object data
*
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="fkOrderShippingMethod", type="integer", nullable=true)
*/
private $fkOrderShippingMethod = '0';
/**
* @var float
*
* @ORM\Column(name="price", type="float", precision=7, scale=2, nullable=false)
*/
private $price = '0.00';
/**
* @var int
*
* @ORM\Column(name="fkProductType", type="integer", nullable=true)
*/
private $fkProductType = '0';
/**
* @var int
*
* @ORM\Column(name="fkBrand", type="integer", nullable=true)
*/
private $fkBrand = '0';
/**
* @var string
*
* @ORM\Column(name="isExpeditable", type="string", length=16, nullable=false)
*/
private $isExpeditable = '0';
/**
* @var string
*
* @ORM\Column(name="expediteDescription", type="text", length=65535, nullable=false)
*/
private $expediteDescription = '';
/**
* @var string
*
* @ORM\Column(name="showLiftGateOption", type="string", length=16, nullable=false)
*/
private $showLiftGateOption = '0';
/**
* @var string
*
* @ORM\Column(name="showDestinationOption", type="string", length=16, nullable=false)
*/
private $showDestinationOption = '0';
/**
* @var string
*
* @ORM\Column(name="productNotAvailable", type="string", length=16, nullable=false)
*/
private $productNotAvailable = '0';
/**
*
* Relationship managment propperties
*
*/
/**
* Many OrderShippingPrices have One OrderShippingMethod.
* @ORM\ManyToOne(targetEntity="OrderShippingMethod", fetch="EAGER")
* @ORM\JoinColumn(name="fkOrderShippingMethod", referencedColumnName="id")
**/
private $orderShippingMethod;
/**
* Get orderOrderShippingMethod
*
* @return OrderShippingMethod
*/
public function getOrderShippingMethod()
{
return $this->orderShippingMethod;
}
/**
*
* Normal string / int getters and setters
*
*/
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set fkOrderShippingMethod
*
* @param string $fkOrderShippingMethod
*
* @return OrderCart
*/
public function setFkOrderShippingMethod($fkOrderShippingMethod)
{
$this->fkOrderShippingMethod = $fkOrderShippingMethod;
return $this;
}
/**
* Get fkOrderShippingMethod
*
* @return string
*/
public function getFkOrderShippingMethod()
{
return $this->fkOrderShippingMethod;
}
/**
* Set price
*
* @param string $price
*
* @return OrderCart
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return string
*/
public function getPrice()
{
return $this->price;
}
/**
* Set fkProductType
*
* @param string $fkProductType
*
* @return OrderCart
*/
public function setFkProductType($fkProductType)
{
$this->fkProductType = $fkProductType;
return $this;
}
/**
* Get fkProductType
*
* @return string
*/
public function getFkProductType()
{
return $this->fkProductType;
}
/**
* Set fkBrand
*
* @param string $fkBrand
*
* @return OrderCart
*/
public function setFkBrand($fkBrand)
{
$this->fkBrand = $fkBrand;
return $this;
}
/**
* Get fkBrand
*
* @return string
*/
public function getFkBrand()
{
return $this->fkBrand;
}
/**
* Set isExpeditable
*
* @param string $isExpeditable
*
* @return OrderCart
*/
public function setIsExpeditable($isExpeditable)
{
$this->isExpeditable = $isExpeditable;
return $this;
}
/**
* Get isExpeditable
*
* @return string
*/
public function getIsExpeditable()
{
return $this->isExpeditable;
}
/**
* Set expediteDescription
*
* @param string $expediteDescription
*
* @return OrderCart
*/
public function setExpediteDescription($expediteDescription)
{
$this->expediteDescription = $expediteDescription;
return $this;
}
/**
* Get expediteDescription
*
* @return string
*/
public function getExpediteDescription()
{
return $this->expediteDescription;
}
/**
* Set showLiftGateOption
*
* @param string $showLiftGateOption
*
* @return OrderCart
*/
public function setShowLiftGateOption($showLiftGateOption)
{
$this->showLiftGateOption = $showLiftGateOption;
return $this;
}
/**
* Get showLiftGateOption
*
* @return string
*/
public function getShowLiftGateOption()
{
return $this->showLiftGateOption;
}
/**
* Set showDestinationOption
*
* @param string $showDestinationOption
*
* @return OrderCart
*/
public function setShowDestinationOption($showDestinationOption)
{
$this->showDestinationOption = $showDestinationOption;
return $this;
}
/**
* Get showDestinationOption
*
* @return string
*/
public function getShowDestinationOption()
{
return $this->showDestinationOption;
}
/**
* Set productNotAvailable
*
* @param string $productNotAvailable
*
* @return OrderCart
*/
public function setProductNotAvailable($productNotAvailable)
{
$this->productNotAvailable = $productNotAvailable;
return $this;
}
/**
* Get productNotAvailable
*
* @return string
*/
public function getProductNotAvailable()
{
return $this->productNotAvailable;
}
}
OrderShippingMethod 包含:
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OrderShippingMethod
*
* @ORM\Table(name="orderShippingMethod")
* @ORM\Entity
*/
class OrderShippingMethod
{
/**
*
* Normal string / int object data
*
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="text", length=255, nullable=false)
*/
private $name = '';
/**
* @var string
*
* @ORM\Column(name="carrier", type="string", length=32, nullable=false)
*/
private $carrier = '';
/**
* @var string
*
* @ORM\Column(name="bvCode", type="string", length=32, nullable=false)
*/
private $bvCode = '';
/**
* @var string
*
* @ORM\Column(name="trackingUrl", type="string", length=255, nullable=true)
*/
private $trackingUrl = '';
/**
* @var int
*
* @ORM\Column(name="minimumLeadTime", type="integer", nullable=false)
*/
private $minimumLeadTime = '0';
/**
* @var int
*
* @ORM\Column(name="maximumLeadTime", type="integer", nullable=false)
*/
private $maximumLeadTime = '0';
/**
*
* Relationship managment propperties
*
*/
/**
* @ORM\OneToMany(targetEntity="OrderShippingMethodRegionMapping", mappedBy="orderShippingMethod", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EAGER")
* @var orderShippingMethodRegionMappings[]
**/
public $orderShippingMethodRegionMappings;
/**
* Constructor
*
* Create array for collection of orderShippingMethodRegionMappings
*/
public function __construct()
{
$this->orderShippingMethodRegionMappings = new ArrayCollection();
}
/**
* Get orderShippingMethodRegionMapping(s)
*
* @return array
*/
public function getOrderShippingMethodRegionMappings()
{
return $this->orderShippingMethodRegionMappings;
}
/**
*
* Normal string / int getters and setters
*
*/
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param int $name
*
* @return OrderCart
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return int
*/
public function getName()
{
return $this->name;
}
/**
* Set carrier
*
* @param string $carrier
*
* @return OrderCart
*/
public function setCarrier($carrier)
{
$this->carrier = $carrier;
return $this;
}
/**
* Get carrier
*
* @return string
*/
public function getCarrier()
{
return $this->carrier;
}
/**
* Set bvCode
*
* @param string $bvCode
*
* @return OrderCart
*/
public function setBvCode($bvCode)
{
$this->bvCode = $bvCode;
return $this;
}
/**
* Get bvCode
*
* @return string
*/
public function getBvCode()
{
return $this->bvCode;
}
/**
* Set trackingUrl
*
* @param string $trackingUrl
*
* @return OrderCart
*/
public function setTrackingUrl($trackingUrl)
{
$this->trackingUrl = $trackingUrl;
return $this;
}
/**
* Get trackingUrl
*
* @return string
*/
public function getTrackingUrl()
{
return $this->trackingUrl;
}
/**
* Set minimumLeadTime
*
* @param string $minimumLeadTime
*
* @return OrderCart
*/
public function setMinimumLeadTime($minimumLeadTime)
{
$this->minimumLeadTime = $minimumLeadTime;
return $this;
}
/**
* Get minimumLeadTime
*
* @return string
*/
public function getMinimumLeadTime()
{
return $this->minimumLeadTime;
}
/**
* Set maximumLeadTime
*
* @param string $maximumLeadTime
*
* @return OrderCart
*/
public function setMaximumLeadTime($maximumLeadTime)
{
$this->maximumLeadTime = $maximumLeadTime;
return $this;
}
/**
* Get maximumLeadTime
*
* @return string
*/
public function getMaximumLeadTime()
{
return $this->maximumLeadTime;
}
}
OrderShippingMethodRegionMapping 包含:
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* OrderShippingMethodRegionMapping
*
* @ORM\Table(name="orderShippingMethodRegionMapping")
* @ORM\Entity
*/
class OrderShippingMethodRegionMapping
{
/**
*
* Normal string / int object data
*
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="fkOrderShippingMethod", type="integer")
*/
private $fkOrderShippingMethod = '0';
/**
* @var int
*
* @ORM\Column(name="fkOrderRegion", type="integer")
*/
private $fkOrderRegion = '0';
/**
*
* Relationship managment propperties
*
*/
/**
* Many OrderShippingPrices have One OrderShippingMethod.
* @ORM\ManyToOne(targetEntity="OrderShippingMethod", inversedBy="orderShippingMethodRegionMappings")
* @ORM\JoinColumn(name="fkOrderShippingMethod", referencedColumnName="id")
**/
private $orderShippingMethod;
/**
* Sets a new OrderShippingMethod and cleans the previous one if set
* @param OrderShippingMethod
*/
public function setOrderShippingMethod(OrderShippingMethod $orderShippingMethod)
{
$this->orderShippingMethod = $orderShippingMethod;
}
/**
* Get orderOrderShippingMethod
*
* @return OrderShippingMethod
*/
public function getOrderShippingMethod()
{
return $this->orderShippingMethod;
}
/**
*
* Normal string / int getters and setters
*
*/
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set fkOrderShippingMethod
*
* @param int $fkOrderShippingMethod
*
* @return OrderCart
*/
public function setFkOrderShippingMethod($fkOrderShippingMethod)
{
$this->fkOrderShippingMethod = $fkOrderShippingMethod;
return $this;
}
/**
* Get fkOrderShippingMethod
*
* @return int
*/
public function getFkOrderShippingMethod()
{
return $this->fkOrderShippingMethod;
}
/**
* Set fkOrderRegion
*
* @param int $fkOrderRegion
*
* @return OrderCart
*/
public function setFkOrderRegion($fkOrderRegion)
{
$this->fkOrderRegion = $fkOrderRegion;
return $this;
}
/**
* Get fkOrderRegion
*
* @return int
*/
public function getFkOrderRegion()
{
return $this->fkOrderRegion;
}
}
有人可以告诉我我做错了什么吗?感谢您的帮助。
您在 innerJoin
方法调用中缺少参数。你必须这样做:
$shippingPriceReccords
= $this->em->createQueryBuilder()
->select('price')
->from('OrderShippingPrice', 'price')
->innerJoin('OrderShippingMethod', 'method', 'WITH', 'price.fkOrderShippingMethod = method.id')
->innerJoin('OrderShippingMethodRegionMapping', 'map', 'WITH', 'map.fkOrderShippingMethod = method.id')
->where('price.fkProductType = :fkProductType')
->andwhere('price.fkBrand = :fkBrand')
->andwhere('map.fkRegion = :fkRegion')
->setParameters([
'fkProductType' => $fkProductType,
'fkBrand' => $fkBrand,
'fkRegion' => $regionID,
])
->getQuery()
->setFetchMode("OrderCart", "address", \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER)
->getResult();
见 documentation :
// Example - $qb->innerJoin('u.Group', 'g', Expr\Join::WITH, $qb->expr()->eq('u.status_id', '?1'))
// Example - $qb->innerJoin('u.Group', 'g', 'WITH', 'u.status = ?1')
// Example - $qb->innerJoin('u.Group', 'g', 'WITH', 'u.status = ?1', 'g.id')
public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null);