title: How can I execute an INSERT query on Twig (symfony 3)?
body: <p>the problem than I want to resolve is than I want to see a list of users, and then I want to have a checkbox next to each user to select if the user is present or if it is ausent. On symfony (basic HTML actually) I can create an array than give me the id of those than I selected previously on the form, but, how can I send that information to the database? since I have this data on the view (which is a twig file on symfony).</p>
  
  <p>So far I have only found this example of how to create a query from twig <a href="https://www.snip2code.com/Snippet/591299/hackishly-using-SQL-in-Twig-templates-in" rel="nofollow">https://www.snip2code.com/Snippet/591299/hackishly-using-SQL-in-Twig-templates-in</a> , but it give me an error since it doesnt recognize the "db", so I cant use it.</p>
  
  <p>So, is there any way to to send that array to the database? Twig seems to limit a lot my options. Thanks</p>
  
  <p>Edit: Correct approach (because someone else will have this noob doubt in the future, as I did) is in the method of the form (easier to make it work by just using html instead of what twig offer) call the method from the controller than you want to call, and there you can get the data with a $_GET or $_POST and then interact with the database with doctrine.</p>