I'm trying to make a application with Silex and I want to create a form which will allow to add things in my database.
I added Symfony's components but I don't find documentation to create this kind of form, only connect forms. How do I use Symfony's components like:
$data = $form->getData();
$app['form']->persist($data);
$app['form']->flush();
return $app->redirect($app['url_generator']->generate('homepage'));
Or should I do something like that?
$data = $form->getData();
$sql = "INSERT INTO `testdb`.`video` (`id` ,`titre`)
VALUES (NULL , $data['name']";
$app['dbs']['mysql_write']->execute($sql);
I'd go for either:
Whatever you do, for the love of god, use prepared statements.