同时使用显示PDO异常错误的学说添加新字段



这是我代码的一部分。 当我第一次创建字段员工时 并键入...它完美地工作...但我试图添加第三个字段 它显示此错误。请帮助我找到错误

    ----------

学说错误显示

      [DoctrineDBALDBALException]                                                
      An exception occurred while executing 'ALTER TABLE leave ADD days VARCHAR(1  
      00) NOT NULL':                                                               
      SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
      n your SQL syntax; check the manual that corresponds to your MySQL server v  
      ersion for the right syntax to use near 'leave ADD days VARCHAR(100) NOT NU  
      LL' at line 1                                                                



      [PDOException]                                                               
      SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
      n your SQL syntax; check the manual that corresponds to your MySQL server v  
      ersion for the right syntax to use near 'leave ADD days VARCHAR(100) NOT NU  
      LL' at line 1                                                               
    ----------

这是我的模特,离开.php

    <?php
    namespace ApplicationModel;
    use DoctrineORMMapping as ORM;
    use DoctrineCommonCollectionsArrayCollection;
    /**
     * @ORMTable(name="leave")
     * @ORMEntity
     */
    class Leave extends Entity
    {
        /**
         * @ORMColumn(type="string", length=100)
         * @var string
         */
        protected $employee;

        public function getEmployee()
        {
            return $this->employee;
        }
        public function setEmployee($emp)
        {
            $this->employee = $emp;
        }
        /**
         * @ORMColumn(type="string", length=100)
         * @var string
         */
        protected $type;

        public function getType()
        {
            return $this->type;
        }
        public function setType($type)
        {
            $this->type = $type;
        }
        /**
         * @ORMColumn(type="string", length=100)
         * @var string
         */
        protected $days;

        public function getDays()
        {
            return $this->days;
        }
        public function setDays($days)
        {
            $this->days = $days;
        }
    }

请参阅 http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words

您需要引用保留字,例如

/**
 * @ORMTable(name="`leave`")
 * @ORMEntity
 */

相关内容

  • 没有找到相关文章

最新更新