This tutorial has a new version, check it out!

Symfony 3: Doctrine & the Database


What you'll be learning

With already two courses checked off, you are primed and ready to put Symfony to work! And that's what this course is all about: making things more interesting by talking to the database with Doctrine.

Doctrine has a reputation for being tough to learn, and that's unfortunate, because it's an amazing tool. In this tutorial, we'll get you rolling with Doctrine: learn how to use it, how to get hard work done easily and how to avoid the common pitfalls that can make Doctrine hard:

  • Creating entity classes
  • Managing migrations
  • Saving new data
  • Querying for data
  • Custom repositories
  • Custom queries and the query builder
  • Fixtures (Dummy data) using Faker

... and (like always) a lot more goodies are mixed in.

Your Guides
Ryan Weaver Leanna Pelham

Buy Access

Questions? Conversation?

  • 2019-08-05 Coder

    Maybe thats a solution - use mysql ogging and set breakpoint after execution and last query should be in mysql log - could take it.

    But I have now taken one answer from SO and added fixes for date parameters and for case when IN is used and so far it works. Postet SO answer.

    Just need to make some script which turns on mysql logging and restarts mysql., so you would not need to waste same amount of time as manually replacing ? marks.

  • 2019-07-24 Diego Aguiar

    Hmm, yeah, I think Doctrine can't do much more for you but you may want to enable MySql logging then. It's not recommended, it may slow down your app but I believe you will use it only for developing


  • 2019-07-23 Coder

    It shows sql queryies but with ? marks and array of parameters after them. I need those ? marks replaced with parameters. I found in stackoverflow one asnwer how to do that but it did not worked with date strings when they were parameters, but I have made a fix, did not test much, but maybe it will work. Then will need to find more convenient way to access it from anywhere.

  • 2019-07-22 Diego Aguiar

    Hey Coder

    You can run your commands passing in -vvv flag to see the exact queries being executed. Give it a try and let me know if it worked


  • 2019-07-21 Coder

    I cant find nowhere one thing, working correctly, its weird, because it should be so useful for many people. When I call getSQL() on query builder, I get only query with ? marks. I want to get often query with filled paramters in question marks, because I want to run it in my database and debug results. And everytyme I do it, I have to manually insert values in ? places. Have tried functions on stackowerflow which claim doing so but for me they did not replace. Or replaces only some times. I assume somewhere has to be this funcgtiotn because profiler shows those values with replaced question marks. Only problem with profiler is when there are like 10 or more queries, it takes tiem to find which you wanted. I use xdebug and when i go to query builder when it is generated, I want to get sql string with replaced values. And also when I run symfony command, probably there is no way to see in profiler those at all.