私はここで、二つのクラスの製品とマネージャを持っているが、各クラスのコードは、(製品には、私はちょうど関連のコードを配置します)です:製品エンティティのDoctrineのエラー:構文エラーまたはアクセス違反:10649
コード:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="products")
* @ORM\Entity
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
*/
class Product {
/**
* @ORM\ManyToMany(targetEntity="Manager", mappedBy="products")
**/
private $manager;
}
そしてここでは、まず、私はマネージャーオブジェクトを作成して、私はマネージャエンティティと製品を作成しています機能を持っている私のコントローラに管理エンティティ
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Table(name="shipping_methods")
* @ORM\Entity
*/
class Manager {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="decimal", precision=8, scale=2, options={"default" = 0})
*/
protected $percentage;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected $name;
/**
* @ORM\Column(type="integer", nullable=false)
*/
protected $quantity;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $where;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $flag;
/**
* @ORM\ManyToMany(targetEntity="Product", inversedBy="shipping")
* @ORM\JoinTable(name="manager_methods")
**/
protected $products;
/**
* Constructor
*/
public function __construct()
{
$this->products = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set percentage
*
* @param string $percentage
* @return Manager
*/
public function setPercentage($percentage)
{
$this->percentage = $percentage;
return $this;
}
/**
* Get percentage
*
* @return string
*/
public function getPercentage()
{
return $this->percentage;
}
/**
* Set name
*
* @param string $name
* @return Manager
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set quantity
*
* @param integer $quantity
* @return Manager
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* Get quantity
*
* @return integer
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* Set where
*
* @param string $where
* @return Manager
*/
public function setWhere($where)
{
$this->where = $where;
return $this;
}
/**
* Get where
*
* @return string
*/
public function getWhere()
{
return $this->where;
}
/**
* Set flag
*
* @param string $flag
* @return Manager
*/
public function setFlag($flag)
{
$this->flag = $flag;
return $this;
}
/**
* Get flag
*
* @return string
*/
public function getFlag()
{
return $this->flag;
}
/**
* Add products
*
* @param \AppBundle\Entity\Product $products
* @return Manager
*/
public function addProduct(\AppBundle\Entity\Product $products)
{
$this->products[] = $products;
return $this;
}
/**
* Remove products
*
* @param \AppBundle\Entity\Product $products
*/
public function removeProduct(\AppBundle\Entity\Product $products)
{
$this->products->removeElement($products);
}
/**
* Get products
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProducts()
{
return $this->products;
}
}
のコードです後でそれらをリンクするProductオブジェクトを作成します。しかし、昨日Managerオブジェクトを挿入しようとしたときから私が見たことのない問題があります。私はここにSymfonyと私がエラーを取得するコードを与えるエラーを貼り付けます。
私はエラーを取得するコード:
$em = $this->getDoctrine()->getManager();
$shipping = new Manager();
$shipping->setPercentage(1);
$shipping->setName("Name");
$shipping->setQuantity(1);
$shipping->setFlag("flag");
$shipping->setWhere("where");
$em->persist($shipping);
$em->flush();
そして、ここでは、Symfonyのからのエラーです:
An exception occurred while executing 'INSERT INTO shipping_methods (percentage, name, quantity, where, flag) VALUES (?, ?, ?, ?, ?)' with params [1, "Name", 1, "where", "flag"]:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where, flag) VALUES ('1', 'Name', 1, 'where', 'flag')' at line 1
誰かが私を助けることができれば、私は原因それに非常に非常に感謝されるだろう、私は本当に午前この問題に固執して...ありがとう!
お知らせどのように1064ポイントを正確に誤りの場所へ。 (時にはいたずらな言葉/句読点が指示された場所の前にありますが、今度はその場所にありました) –