【发布时间】:2017-06-27 17:29:10
【问题描述】:
我有一个无法修复的错误,因为我找不到问题所在。 控制台中的错误说:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting ',' or ';'
尝试使用时:
php bin/console doctrine:schema:update --dump-sql
我正在尝试为我的学习分配作业,但我找不到问题所在。 在实体“client_order.php”中添加下一个字段后,该命令不起作用:
/**
* @ORM\ManyToOne(targetEntity="order_line")
* @ORM\JoinColumn(name="order_line_id", referencedColumnName="id")
*/
private $order_line;
/**
* @ORM\ManyToOne(targetEntity="user")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="Product")
* @ORM\JoinColumn(name="Product_id", referencedColumnName="id")
*/
private $Product;
在 symfony 中添加新字段后,我使用了以下命令:
php bin/console doctrine:generate:entities TuinadviesBundle:client_order
这是完整的文档:
namespace TuinadviesBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* client_order
*
* @ORM\Table(name="client_order")
* @ORM\Entity(repositoryClass="TuinadviesBundle\Repository\client_orderRepository")
*/
class client_order
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="date", type="date")
*/
private $date;
/**
* @var \DateTime
*
* @ORM\Column(name="expiration_date", type="date")
*/
private $expirationDate;
/**
* @ORM\ManyToOne(targetEntity="order_line")
* @ORM\JoinColumn(name="order_line_id", referencedColumnName="id")
*/
private $order_line;
/**
* @ORM\ManyToOne(targetEntity="user")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="Product")
* @ORM\JoinColumn(name="Product_id", referencedColumnName="id")
*/
private $Product;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set date
*
* @param \DateTime $date
*
* @return client_order
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* Get date
*
* @return \DateTime
*/
public function getDate()
{
return $this->date;
}
/**
* Set expirationDate
*
* @param \DateTime $expirationDate
*
* @return client_order
*/
public function setExpirationDate($expirationDate)
{
$this->expirationDate = $expirationDate;
return $this;
}
/**
* Get expirationDate
*
* @return \DateTime
*/
public function getExpirationDate()
{
return $this->expirationDate;
}
/**
* Set orderLine
*
* @param \TuinadviesBundle\Entity\order_line $orderLine
*
* @return client_order
*/
public function setOrderLine(\TuinadviesBundle\Entity\order_line $orderLine = null)
{
$this->order_line = $orderLine;
return $this;
}
/**
* Get orderLine
*
* @return \TuinadviesBundle\Entity\order_line
*/
public function getOrderLine()
{
return $this->order_line;
}
/**
* Set user
*
* @param \TuinadviesBundle\Entity\user $user
*
* @return client_order
*/
public function setUser(\TuinadviesBundle\Entity\user $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \TuinadviesBundle\Entity\user
*/
public function getUser()
{
return $this->user;
}
/**
* Set product
*
* @param \TuinadviesBundle\Entity\Product $product
*
* @return client_order
*/
public function setProduct(\TuinadviesBundle\Entity\Product $product = null)
{
$this->Product = $product;
return $this;
}
/**
* Get product
*
* @return \TuinadviesBundle\Entity\Product
*/
public function getProduct()
{
return $this->Product;
}
}
我添加的所有类都是正确的(即使是带有大写 P 的 Product(这是错误的))。
谁能告诉我我做错了什么?
提前致谢:)
【问题讨论】:
-
order_line 中的下划线将成为问题,所以它是 orderLine 看看是否可以解决它(包括在 getter/setter 中)
-
感谢您的回复,但很遗憾没有成功:(
-
您确定问题与这个特定的
client_order类有关吗?因为您还有至少 3 个其他实体并且尚未共享他们的代码。无论如何,您可以在详细模式下运行命令吗?php bin/console doctrine:schema:update --dump-sql -vvv并分享输出? -
我想我是因为它在我添加这些之前就起作用了。但我会在一个新问题中发布它
标签: php symfony doctrine-orm many-to-one