Skip to content
Advertisement

Fetching objects from database in Symfony

I have entity Domain which has fields id, domain, users in field users, I have an id which is the id of the user who created that domain.

now I have created for in the template which will display every domain that the user created.

I messed it up somehow and I don’t know how to solve it.

workspaces.html.twig

JavaScript

MainController.php

JavaScript

DomainRepository.php

JavaScript

Error that I get: Key “domain” for an array with keys “0, 1” does not exist. currently, I got 2 records in the database but when I add more then the error shows more keys “0, 1, 2…”

I know that I somehow messed up for or something (bad naming does not help 🙁 ).

Advertisement

Answer

Did you check your query if its working? if its working there is a problem in your code

First let’s clean a little the code.

MainController.php

JavaScript

DomainRepository.php

JavaScript

workspaces.html.twig

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement