douzhao9608
2012-02-09 17:03
浏览 19
已采纳

使用表单与数据库交互

I'm trying to make a application with Silex and I want to create a form wich 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 can i do to 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);

Thanx for your help.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题