I have a User
entity. One user can buy a product. After the form validation I want to store the user data (ID, name, mail, password, address, ..) in $session
, and only after the success payment retrieve this data from session and store it to the db.
This is what I'm doing: (if the from is valid)
$session = new Session();
$serialized_user = serialize($user);
$session->set('myuser', ($serialized_user));
Then, after the payment check:
$test = ($this->get('session')->get('myuser'));
$test_unserialized = unserialize($test);
$em = $this->getDoctrine()->getManager();
$em->persist($test_unserialized);
$em->flush();
return $this->render('UserBundle:Account:buyedOk.php');
What I got is this error:
An exception occurred while executing 'INSERT INTO user (user, passw, email, is_active, is_locked, date_expire, date_registration, last_visit, name, surname, address, zipcode, city, province, country, vat, tel, fax, contact_name, contact_role, contact_email, contact_tel, email_hex, email_confirmed, validated,id_currency) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["March", "$2y$13$hTBP0ANwRlwgcfX19OtsTubn6ctI64lz5GVQ3JF3nZtD0GDPK8rTC", null, 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'email' cannot be null
Suggestions?