Тема: Doctrine ORM SQLSTATE[42000]
Народ, виникла проблема яка мене вже *$@% ... допекла...
Вот помилка:
Doctrine\DBAL\DBALException
File:
C:\xampp\htdocs\o0ps.ua\www\vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php:47
Message:
An exception occurred while executing 'INSERT INTO order (name, mail, text) VALUES (?, ?, ?)' with params ["dgrrger", "vdsvs@eger.ua", "67u76u67ut"]: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 (name, mail, text) VALUES ('dgrrger', 'vdsvs@eger.ua', '67u76u67ut')' at line 1
PDOException
File:
C:\xampp\htdocs\o0ps.ua\www\vendor\doctrine\dbal\lib\Doctrine\DBAL\Statement.php:138
Message:
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 (name, mail, text) VALUES ('dgrrger', 'vdsvs@eger.ua', '67u76u67ut')' at line 1
Вот Entity:
<?php
namespace Portfolio\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @ORM\Entity
* @ORM\Table(name="order")
*/
class Order
{
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected $name;
/**
* @var mail
* @ORM\Column(type="text")
*/
protected $mail;
/**
* @var text
* @ORM\Column(type="text")
*/
protected $text;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set id.
*
* @param int $id
*
* @return void
*/
public function setId($id)
{
$this->id = (int)$id;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set name.
*
* @param string $name
*
* @return void
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get mail.
*
* @return string
*/
public function getMail()
{
return $this->mail;
}
/**
* Set mail.
*
* @param string $mail
*
* @return void
*/
public function setMail($mail)
{
$this->mail = $mail;
}
/**
* Get text.
*
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* Set text.
*
* @param string $text
*
* @return void
*/
public function setText($text)
{
$this->text = $text;
}
/**
* Helper function.
*/
public function exchangeArray($data)
{
foreach ($data as $key => $val) {
if (property_exists($this, $key)) {
$this->$key = ($val !== null) ? $val : null;
}
}
}
/**
* Helper function
*/
public function getArrayCopy()
{
return get_object_vars($this);
}
}
Контроллер:
<?php
namespace Portfolio\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class OrderController extends AbstractActionController
{
const ENTITY_MANAGER = 'Doctrine\ORM\EntityManager';
const ENTITY_PATCH = '\Portfolio\Entity\Order';
const ORDER_FORM = '\Portfolio\Form\OrderForm';
const ORDER_FILTER = '\Portfolio\Form\OrderFilter';
const ROUTE_AFTER_INDEX = 'home';
const ROUTE_AFTER_ADD = 'home';
const ORDER_IS_NOT_EXISTS = 'Файл не знайдено';
const ERROR = 'Невідома помилка. Попробуйте ще раз';
const ERROR_INVALID_FORM = 'Форма неправильно заповнена. Попробуйте ще раз';
/**
* @var OrderForm
*/
public $OrderForm;
/**
* @return array|\Zend\Http\Response
*/
public function indexAction()
{
return $this->redirect()->toRoute(static::ROUTE_AFTER_INDEX);
}
/**
* @return \Zend\Http\Response|ViewModel
*/
public function addAction()
{
$form = $this->getOrderForm();
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost()->toArray();
$form->setData($data);
if ($form->isValid()) {
$objectManager = $this->getServiceLocator()->get(static::ENTITY_MANAGER);
$entityPatch = static::ENTITY_PATCH;
$order = new $entityPatch();
$order->exchangeArray($form->getData());
$objectManager->persist($order);
$objectManager->flush();
return $this->redirect()->toRoute(static::ROUTE_AFTER_ADD);
} else {
return new ViewModel(array(
'error' => static::ERROR_INVALID_FORM,
'form' => $form
));
}
}
return new ViewModel(array(
'form' => $form
));
}
/**
* @return UploadFilterForm|\Portfolio\Form\FileUploadForm
*/
public function getOrderForm()
{
if (!$this->OrderForm) {
$orderForm = static::ORDER_FORM;
$orderFilter = static::ORDER_FILTER;
$this->OrderForm = new $orderForm();
$this->OrderForm->setInputFilter(new $orderFilter());
}
return $this->OrderForm;
}
}
module.config:
...
'doctrine' => array(
'driver' => array(
'portfolio_entity' => array(
'class' =>'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'paths' => array(__DIR__ . '/../src/Portfolio/Entity')
),
'orm_default' => array(
'drivers' => array(
'Portfolio\Entity' => 'portfolio_entity',
)
)
)
)
...
А це БД:
А весь прикол в тому, що в цьому самому модулі є інший enity для роботи з портфоліо і він пашить чудово...
В чому проблема?