我无法通过表单创建我的实体,因为我遇到了这个错误:
CRITICAL - 未捕获的PHP异常Doctrine \ DBAL \ DBALException:“An 执行'INSERT INTO Task(标题,misc, url,attachment,time_estimated,started_at,finished_at,default, 截止日期,task_priority_id,task_id,project_id,task_category_id, user_id)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)' params [“Test”,null,null,null,null,null,null,0,null,15,null, 2,44,5:SQLSTATE [42000]:语法错误或访问冲突:1064你 您的SQL语法有错误;检查对应的手册 您的MySQL服务器版本,以便在'default,'附近使用正确的语法 截止日期,task_priority_id,task_id,project_id,task_category_id, 用户'在第1行“ C:\ LanTools \ xampp \ htdocs \ sf2_akimedia-crm \ vendor \ doctrine \ dbal \ lib \ Doctrine \ DBAL \ DBALException.php第91行
这是我的任务实体:
use Doctrine\ORM\Mapping AS ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="Lan\CrmBundle\Entity\TaskRepository")
*
*/
class Task
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $misc;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $url;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $attachment;
/**
* @ORM\ManyToOne(targetEntity="Lan\CrmBundle\Entity\TaskPriority", inversedBy="tasks")
* @ORM\JoinColumn(name="task_priority_id", referencedColumnName="id", nullable=false)
*/
private $priority;
/**
* @ORM\ManyToOne(targetEntity="Lan\CrmBundle\Entity\Task", inversedBy="tasks")
* @ORM\JoinColumn(name="task_id", referencedColumnName="id")
*/
private $task;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $time_estimated;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $started_at;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $finished_at;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $default;
/**
* @ORM\OneToMany(targetEntity="Lan\CrmBundle\Entity\Task", mappedBy="task")
*/
private $tasks;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $deadline;
/**
* @ORM\OneToMany(targetEntity="Lan\CrmBundle\Entity\Comment", mappedBy="task")
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity="Lan\CrmBundle\Entity\Account", mappedBy="task")
*/
private $accounts;
/**
* @ORM\ManyToOne(targetEntity="Lan\CrmBundle\Entity\Project", inversedBy="tasks")
* @ORM\JoinColumn(name="project_id", referencedColumnName="id", nullable=false)
*/
private $project;
/**
* @ORM\ManyToOne(targetEntity="Lan\CrmBundle\Entity\TaskCategory", inversedBy="tasks")
* @ORM\JoinColumn(name="task_category_id", referencedColumnName="id", nullable=false)
*/
private $category;
/**
* @ORM\ManyToOne(targetEntity="Lan\SecurityBundle\Entity\User", inversedBy="tasks")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
*/
private $user;
/**
*
*/
private $products;
/**
* Constructor
*/
public function __construct()
{
$this->comments = new \Doctrine\Common\Collections\ArrayCollection();
$this->accounts = new \Doctrine\Common\Collections\ArrayCollection();
$this->products = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
*
*/
public function setStartedAtValue()
{
$this->started_at = new \DateTime();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
* @return Task
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set misc
*
* @param string $misc
* @return Task
*/
public function setMisc($misc)
{
$this->misc = $misc;
return $this;
}
/**
* Get misc
*
* @return string
*/
public function getMisc()
{
return $this->misc;
}
/**
* Set url
*
* @param string $url
* @return Task
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set attachment
*
* @param string $attachment
* @return Task
*/
public function setAttachment($attachment)
{
$this->attachment = $attachment;
return $this;
}
/**
* Get attachment
*
* @return string
*/
public function getAttachment()
{
return $this->attachment;
}
/**
* Set priority
*
* @param integer $priority
* @return Task
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return integer
*/
public function getPriority()
{
return $this->priority;
}
/**
* Set time_estimated
*
* @param float $timeEstimated
* @return Task
*/
public function setTimeEstimated($timeEstimated)
{
$this->time_estimated = $timeEstimated;
return $this;
}
/**
* Get time_estimated
*
* @return float
*/
public function getTimeEstimated()
{
return $this->time_estimated;
}
/**
* Set started_at
*
* @param \DateTime $startedAt
* @return Task
*/
public function setStartedAt($startedAt)
{
$this->started_at = $startedAt;
return $this;
}
/**
* Get started_at
*
* @return \DateTime
*/
public function getStartedAt()
{
return $this->started_at;
}
/**
* Set finished_at
*
* @param \DateTime $finishedAt
* @return Task
*/
public function setFinishedAt($finishedAt)
{
$this->finished_at = $finishedAt;
return $this;
}
/**
* Get finished_at
*
* @return \DateTime
*/
public function getFinishedAt()
{
return $this->finished_at;
}
/**
* Set default
*
* @param boolean $default
* @return Task
*/
public function setDefault($default)
{
$this->default = $default;
return $this;
}
/**
* Get default
*
* @return boolean
*/
public function getDefault()
{
return $this->default;
}
/**
* Add comments
*
* @param \Lan\CrmBundle\Entity\Comment $comments
* @return Task
*/
public function addComment(\Lan\CrmBundle\Entity\Comment $comments)
{
$this->comments[] = $comments;
return $this;
}
/**
* Remove comments
*
* @param \Lan\CrmBundle\Entity\Comment $comments
*/
public function removeComment(\Lan\CrmBundle\Entity\Comment $comments)
{
$this->comments->removeElement($comments);
}
/**
* Get comments
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getComments()
{
return $this->comments;
}
/**
* Add accounts
*
* @param \Lan\CrmBundle\Entity\Account $accounts
* @return Task
*/
public function addAccount(\Lan\CrmBundle\Entity\Account $accounts)
{
$this->accounts[] = $accounts;
return $this;
}
/**
* Remove accounts
*
* @param \Lan\CrmBundle\Entity\Account $accounts
*/
public function removeAccount(\Lan\CrmBundle\Entity\Account $accounts)
{
$this->accounts->removeElement($accounts);
}
/**
* Get accounts
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getAccounts()
{
return $this->accounts;
}
/**
* Set project
*
* @param \Lan\CrmBundle\Entity\Project $project
* @return Task
*/
public function setProject(\Lan\CrmBundle\Entity\Project $project)
{
$this->project = $project;
return $this;
}
/**
* Get project
*
* @return \Lan\CrmBundle\Entity\Project
*/
public function getProject()
{
return $this->project;
}
/**
* Set category
*
* @param \Lan\CrmBundle\Entity\TaskCategory $category
* @return Task
*/
public function setCategory(\Lan\CrmBundle\Entity\TaskCategory $category)
{
$this->category = $category;
return $this;
}
/**
* Get category
*
* @return \Lan\CrmBundle\Entity\TaskCategory
*/
public function getCategory()
{
return $this->category;
}
/**
* Add products
*
* @param \Lan\CrmBundle\Entity\Product $products
* @return Task
*/
public function addProduct(\Lan\CrmBundle\Entity\Product $products)
{
$this->products[] = $products;
return $this;
}
/**
* Remove products
*
* @param \Lan\CrmBundle\Entity\Product $products
*/
public function removeProduct(\Lan\CrmBundle\Entity\Product $products)
{
$this->products->removeElement($products);
}
/**
* Get products
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProducts()
{
return $this->products;
}
/**
* Set user
*
* @param \Lan\SecurityBundle\Entity\User $user
* @return Task
*/
public function setUser(\Lan\SecurityBundle\Entity\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \Lan\SecurityBundle\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* Set deadline
*
* @param \DateTime $deadline
* @return Task
*/
public function setDeadline($deadline)
{
$this->deadline = $deadline;
return $this;
}
/**
* Get deadline
*
* @return \DateTime
*/
public function getDeadline()
{
return $this->deadline;
}
/**
* Set task
*
* @param \Lan\CrmBundle\Entity\Task $task
* @return Task
*/
public function setTask(\Lan\CrmBundle\Entity\Task $task = null)
{
$this->task = $task;
return $this;
}
/**
* Get task
*
* @return \Lan\CrmBundle\Entity\Task
*/
public function getTask()
{
return $this->task;
}
/**
* Add tasks
*
* @param \Lan\CrmBundle\Entity\Task $tasks
* @return Task
*/
public function addTask(\Lan\CrmBundle\Entity\Task $tasks)
{
$this->tasks[] = $tasks;
return $this;
}
/**
* Remove tasks
*
* @param \Lan\CrmBundle\Entity\Task $tasks
*/
public function removeTask(\Lan\CrmBundle\Entity\Task $tasks)
{
$this->tasks->removeElement($tasks);
}
/**
* Get tasks
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTasks()
{
return $this->tasks;
}
}
不要犹豫,向我提出任何进一步的信息。
答案 0 :(得分:4)
default
是mysql保留字,你必须通过以下方法解决:
/**
* @ORM\Column(name="`default`", type="boolean", nullable=true)
*/
private $default;