SQLSTATE[42000]: Syntax error or access violation: 1064 Symfony 2.7.3 application
<p>i get the below error when i try to create my product entity:</p>
<blockquote>
<p>An exception occurred while executing 'INSERT INTO products (code, name, description, order, stock, entry, created, manufactured, expire, opening_quantity, purchase_price, opening_price, price, visible, discontinue, view, about, brand_id, groups_id, measurement_id, gender_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [432211, &quot;trolly bag&quot;, &quot;description&quot;, 0, 2, &quot;2016-02-01 15:02:57&quot;, &quot;2016-02-01 15:02:57&quot;, &quot;2011-03-08&quot;, &quot;2016-09-12&quot;, 2, 100, 100, 100, 1, 0, 0, &quot;about&quot;, 2, 2, null, null]:</p>
<p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order, stock, entry, created, manufactured, expire, opening_quantity, purchase_p' at line 1</p>
</blockquote>
<p>Product Entity:</p>
<p>enter code here namespace AppBundle\Entity;</p>
<pre><code>use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name=&quot;products&quot;)
 * @ORM\HasLifecycleCallbacks
 * @ORM\Entity(repositoryClass=&quot;AppBundle\Repository\ProductRepository&quot;)
 */

class Product
{
/**
 * @ORM\Column(type=&quot;integer&quot;)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)
 */
protected $id;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $code;
/**
 * @ORM\Column(type=&quot;string&quot;, length=100)
 */
protected $name;
/**
 * @ORM\Column(type=&quot;text&quot;)
 */
protected $description;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $order;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $stock;
/**
 * @ORM\Column(type=&quot;datetime&quot;)
 */
protected $entry;
/**
 * @ORM\Column(type=&quot;datetime&quot;)
 */
protected $created;
/**
 * @ORM\Column(type=&quot;date&quot;)
 */
protected $manufactured;
/**
 * @ORM\Column(type=&quot;date&quot;)
 *
 */
protected $expire;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $openingQuantity;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $purchasePrice;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $openingPrice;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $price;
/**
 * @ORM\Column(type=&quot;smallint&quot;)
 */
protected $visible;
/**
 * @ORM\Column(type=&quot;smallint&quot;)
 */
protected $discontinue;
/**
 * @ORM\Column(type=&quot;integer&quot;)
 */
protected $view;
/**
 * @ORM\Column(type=&quot;text&quot;)
 */
protected $about;

/**
 * @ORM\ManyToOne(targetEntity=&quot;Brand&quot;, inversedBy=&quot;product&quot;)
 * @ORM\JoinColumn(name=&quot;brand_id&quot;, referencedColumnName=&quot;id&quot;)
 */
protected $brand;

/**
 * @ORM\ManyToOne(targetEntity=&quot;Group&quot;, inversedBy=&quot;product&quot;)
 * @ORM\JoinColumn(name=&quot;groups_id&quot;, referencedColumnName=&quot;id&quot;)
 */
protected $group;

/**
 * @ORM\ManyToOne(targetEntity=&quot;Measurement&quot;, inversedBy=&quot;product&quot;)
 * @ORM\JoinColumn(name=&quot;measurement_id&quot;, referencedColumnName=&quot;id&quot;)
 */
protected $measurement;
/**
 * @ORM\ManyToOne(targetEntity=&quot;Gender&quot;, inversedBy=&quot;product&quot;)
 * @ORM\JoinColumn(name=&quot;gender_id&quot;, referencedColumnName=&quot;id&quot;)
 */
protected $gender;


/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this-&gt;id;
}

/**
 * Set code
 *
 * @param integer $code
 * @return Product
 */
public function setCode($code)
{
    $this-&gt;code = $code;

    return $this;
}

/**
 * Get code
 *
 * @return integer 
 */
public function getCode()
{
    return $this-&gt;code;
}

/**
 * Set name
 *
 * @param string $name
 * @return Product
 */
public function setName($name)
{
    $this-&gt;name = $name;

    return $this;
}

/**
 * Get name
 *
 * @return string 
 */
public function getName()
{
    return $this-&gt;name;
}

/**
 * Set description
 *
 * @param string $description
 * @return Product
 */
public function setDescription($description)
{
    $this-&gt;description = $description;

    return $this;
}

/**
 * Get description
 *
 * @return string 
 */
public function getDescription()
{
    return $this-&gt;description;
}

/**
 * Set order
 *
 * @param integer $order
 * @return Product
 */
public function setOrder($order)
{
    $this-&gt;order = $order;

    return $this;
}

/**
 * Get order
 *
 * @return integer 
 */
public function getOrder()
{
    return $this-&gt;order;
}

/**
 * Set stock
 *
 * @param integer $stock
 * @return Product
 */
public function setStock($stock)
{
    $this-&gt;stock = $stock;

    return $this;
}

/**
 * Get stock
 *
 * @return integer 
 */
public function getStock()
{
    return $this-&gt;stock;
}

/**
 * Set entry
 *
 * @param \DateTime $entry
 * @return Product
 */
public function setEntry($entry)
{
    $this-&gt;entry = $entry;

    return $this;
}

/**
 * Get entry
 *
 * @return \DateTime 
 */
public function getEntry()
{
    return $this-&gt;entry;
}

/**
 * Set created
 *
 * @param \DateTime $created
 * @return Product
 */
public function setCreated($created)
{
    $this-&gt;created = $created;

    return $this;
}

/**
 * Get created
 *
 * @return \DateTime 
 */
public function getCreated()
{
    return $this-&gt;created;
}

/**
 * Set manufactured
 *
 * @param \DateTime $manufactured
 * @return Product
 */
public function setManufactured($manufactured)
{
    $this-&gt;manufactured = $manufactured;

    return $this;
}

/**
 * Get manufactured
 *
 * @return \DateTime 
 */
public function getManufactured()
{
    return $this-&gt;manufactured;
}

/**
 * Set expire
 *
 * @param \DateTime $expire
 * @return Product
 */
public function setExpire($expire)
{
    $this-&gt;expire = $expire;

    return $this;
}

/**
 * Get expire
 *
 * @return \DateTime 
 */
public function getExpire()
{
    return $this-&gt;expire;
}

/**
 * Set openingQuantity
 *
 * @param integer $openingQuantity
 * @return Product
 */
public function setOpeningQuantity($openingQuantity)
{
    $this-&gt;openingQuantity = $openingQuantity;

    return $this;
}

/**
 * Get openingQuantity
 *
 * @return integer 
 */
public function getOpeningQuantity()
{
    return $this-&gt;openingQuantity;
}

/**
 * Set purchasePrice
 *
 * @param integer $purchasePrice
 * @return Product
 */
public function setPurchasePrice($purchasePrice)
{
    $this-&gt;purchasePrice = $purchasePrice;

    return $this;
}

/**
 * Get purchasePrice
 *
 * @return integer 
 */
public function getPurchasePrice()
{
    return $this-&gt;purchasePrice;
}

/**
 * Set openingPrice
 *
 * @param integer $openingPrice
 * @return Product
 */
public function setOpeningPrice($openingPrice)
{
    $this-&gt;openingPrice = $openingPrice;

    return $this;
}

/**
 * Get openingPrice
 *
 * @return integer 
 */
public function getOpeningPrice()
{
    return $this-&gt;openingPrice;
}

/**
 * Set price
 *
 * @param integer $price
 * @return Product
 */
public function setPrice($price)
{
    $this-&gt;price = $price;

    return $this;
}

/**
 * Get price
 *
 * @return integer 
 */
public function getPrice()
{
    return $this-&gt;price;
}

/**
 * Set visible
 *
 * @param integer $visible
 * @return Product
 */
public function setVisible($visible)
{
    $this-&gt;visible = $visible;

    return $this;
}

/**
 * Get visible
 *
 * @return integer 
 */
public function getVisible()
{
    return $this-&gt;visible;
}

/**
 * Set discontinue
 *
 * @param integer $discontinue
 * @return Product
 */
public function setDiscontinue($discontinue)
{
    $this-&gt;discontinue = $discontinue;

    return $this;
}

/**
 * Get discontinue
 *
 * @return integer 
 */
public function getDiscontinue()
{
    return $this-&gt;discontinue;
}

/**
 * Set view
 *
 * @param integer $view
 * @return Product
 */
public function setView($view)
{
    $this-&gt;view = $view;

    return $this;
}

/**
 * Get view
 *
 * @return integer 
 */
public function getView()
{
    return $this-&gt;view;
}

/**
 * Set about
 *
 * @param string $about
 * @return Product
 */
public function setAbout($about)
{
    $this-&gt;about = $about;

    return $this;
}

/**
 * Get about
 *
 * @return string 
 */
public function getAbout()
{
    return $this-&gt;about;
}

/**
 * Set brand
 *
 * @param \AppBundle\Entity\Brand $brand
 * @return Product
 */
public function setBrand(\AppBundle\Entity\Brand $brand = null)
{
    $this-&gt;brand = $brand;

    return $this;
}

/**
 * Get brand
 *
 * @return \AppBundle\Entity\Brand 
 */
public function getBrand()
{
    return $this-&gt;brand;
}

/**
 * Set measurement
 *
 * @param \AppBundle\Entity\Measurement $measurement
 * @return Product
 */
public function setMeasurement(\AppBundle\Entity\Measurement $measurement = null)
{
    $this-&gt;measurement = $measurement;

    return $this;
}

/**
 * Get measurement
 *
 * @return \AppBundle\Entity\Measurement 
 */
public function getMeasurement()
{
    return $this-&gt;measurement;
}

/**
 * Set gender
 *
 * @param \AppBundle\Entity\Gender $gender
 * @return Product
 */
public function setGender(\AppBundle\Entity\Gender $gender = null)
{
    $this-&gt;gender = $gender;

    return $this;
}

/**
 * Get gender
 *
 * @return \AppBundle\Entity\Gender 
 */
public function getGender()
{
    return $this-&gt;gender;
}

/**
 * Set group
 *
 * @param \AppBundle\Entity\Group $group
 * @return Product
 */
public function setGroup(\AppBundle\Entity\Group $group = null)
{
    $this-&gt;group = $group;

    return $this;
}

/**
 * Get group
 *
 * @return \AppBundle\Entity\Group 
 */
public function getGroup()
{
    return $this-&gt;group;
}
}
</code></pre>
<p>Controller:</p>
<pre><code>namespace AppBundle\Controller\admin;

use AppBundle\Entity\Product;

use AppBundle\Form\Type\ProductType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;


class ProductController extends Controller
{
/**
 * @Route(&quot;/admin/product/create/{group_id}&quot;, name=&quot;create group         product&quot;)
 */
public function groupProductCreateAction(Request $request,$group_id)
{

    $Group = $this-&gt;getDoctrine()-&gt;getRepository('AppBundle:Group');

    $group =  $Group-&gt;findOneById($group_id);

    $product = new Product();

    $form = $this-&gt;createForm(new ProductType(), $product)
        -&gt;add('save', 'submit', array(
            'label' =&gt; 'Save',
            'attr'=&gt;array('class'=&gt;'btn btn-md btn-info')
        ));

    $form-&gt;handleRequest($request);

    if ($form-&gt;isValid()) {
        $openingStock = $product-&gt;getOpeningQuantity();
        $openingPrice = $product-&gt;getPrice();
        $product-&gt;setOrder(0);
        $product-&gt;setStock($openingStock);
        $product-&gt;setEntry(new \DateTime());
        $product-&gt;setCreated(new \DateTime());
        $product-&gt;setOpeningPrice($openingPrice);
        $product-&gt;setDiscontinue(0);
        $product-&gt;setView(0);
        $product-&gt;setGroup($group);


        $em = $this-&gt;getDoctrine()-&gt;getManager();
        $em-&gt;persist($product);
        $em-&gt;flush();
        return $this-&gt;redirect($this-&gt;generateUrl('create category       group',
            array('category_id' =&gt; $group_id, )));
    }

    return $this-&gt;render('admin/product.html.twig', array(
        'form' =&gt; $form -&gt;createView(),
    ));
}
</code></pre>