首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Symfony原则语法错误或访问冲突:

Symfony原则语法错误或访问冲突:
EN

Stack Overflow用户
提问于 2016-06-17 16:06:32
回答 1查看 1.3K关注 0票数 0

我正在学习symfony,并试图应用Doctrine一章“创建数据库表模式”一节中所解释的内容。我运行以下命令:

代码语言:javascript
运行
复制
php bin/console doctrine:schema:update --force --dump-sql

我会犯错误:

原则\DBAL\例外\SyntaxErrorException 执行'CREATE TABLE vente\produit (id INT AUTO_INCREMENT NOT NULL,nom VARCHAR(28) NULL,prix双进离子默认值NULL,Descro LONGTEXT NULL,主键(Id))默认字符集utf8 COLLATE utf8_unicode_ci ENGINE =InnoDB‘时发生异常: SQLSTATE42000:语法错误或访问冲突: 1064在您的utf8_unicode_ci语法中有一个错误;检查与您的MariaDB服务器版本相对应的手册,以获得正确的语法以使用NOT '\produit (id INT AUTO_INCREMENT NOT NULL,nom VARCHAR(28) NULL),SQLSTATE42000:语法错误或访问冲突:在您的SQL语法中有一个错误;检查与您的MariaDB服务器版本相对应的手册,以获得正确的语法以使用NOT '\produit (id INT AUTO_INCREMENT NOT NULL,nom VARCHAR(28) NULL),在第1行PDOException SQLSTATE42000:语法错误或访问冲突: 1064您的SQL语法出现了错误;检查与您的MariaDB服务器版本对应的手册,以获得在第1行使用“\produit (id INT AUTO_INCREMENT NULL,near (28) NULL,prix”)的正确语法。

代码语言:javascript
运行
复制
                                                                         .

如果我直接从mysql>提示符运行转储,它会正确地创建表--我的实体是这样一个:

代码语言:javascript
运行
复制
<?php

namespace AppBundle\Entity\Vente;

use Doctrine\ORM\Mapping as ORM;

/**
 * Produit
 *
 * @ORM\Table(name="vente\produit")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\Vente\ProduitRepository")
 */
class Produit
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="nom", type="string", length=28)
     */
    private $nom;

    /**
     * @var float
     *
     * @ORM\Column(name="prix", type="float", nullable=true)
     */
    private $prix;

    /**
     * @var string
     *
     * @ORM\Column(name="Descro", type="text")
     */
    private $descro;


    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nom
     *
     * @param string $nom
     *
     * @return Produit
     */
    public function setNom($nom)
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * Get nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set prix
     *
     * @param float $prix
     *
     * @return Produit
     */
    public function setPrix($prix)
    {
        $this->prix = $prix;

        return $this;
    }

    /**
     * Get prix
     *
     * @return float
     */
    public function getPrix()
    {
        return $this->prix;
    }

    /**
     * Set descro
     *
     * @param string $descro
     *
     * @return Produit
     */
    public function setDescro($descro)
    {
        $this->descro = $descro;

        return $this;
    }

    /**
     * Get descro
     *
     * @return string
     */
    public function getDescro()
    {
        return $this->descro;
    }
}
EN

回答 1

Stack Overflow用户

发布于 2016-06-17 18:00:35

事实上,问题在于我将实体放在"AppBundle/ entity“的子文件夹"Vente”中。它产生了一个奇怪的表名Vente/Produit。把它直接放进实体解决了麻烦。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37885950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档