Save Request class object to database - Symfony2

67 Views Asked by At

How can a Request class object be stored in the MYSQL database and be fetched again as an object ? For now I'm converting it into array and then storing in the database as a serialized value and unserializing after fetching. Is there a can save and fetch the Object directly ?

public function createTask (Request $request) {
  $task = new Task();
  if ($request->isMethod('POST')) {
     $params = $request->request->all();
  } else $params = $request->query->all();
  $task->saveRequest(serialize($params));
}
0

There are 0 best solutions below