Reputation: 174
in my case
symfony2
try to flush my rows on loop but i got error.
what did i miss ?
foreach ($request->request as $key => $val) {
$form_result->setTitle($request->request->get('form-title-title-12431243'));
$form_result->setFieldId($request->request->get('form-title-id-12431243'));
$form_result->setKey($key);
$form_result->setIp($request->getClientIp());
$form_result->setType($request->request->get('form-title-type-12431243'));
$form_result->setValue($val);
$em->persist($form_result);
$em->flush();
}
error :
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 'key, type, field_id, ip) VALUES ('test', 'test', 'form-title-title-12431243', 't' at line 1
Upvotes: 1
Views: 398
Reputation: 884
Column named key
is reserved word in MySQL. It's good practice to avoid using reserved keywords, but in cases you must use it use reserved words quoting to fix the issue.
Upvotes: 1
Reputation: 1055
key
is reserved word in MySQL. Use reserved words quoting to fix the issue.
Upvotes: 1