Majdi Taleb
Majdi Taleb

Reputation: 761

Create table in symfony2

I want to create a table of objects in Symfony2 from different entities. I have two entities: entity user and account. I have to retrieve the information from these two entities and build a table that contains information from both table and return the table result as a response and send it in an email.

for example, I have tow entity in database: table user and table account,

In my controller, I want to get the data from two table and fuse the data into new table (not in database), just multidimensional table. getting the data from two table is easy, but how I can't create an array of object in symfony that contains all data retrieved

 listsofaccounts=$em->getRepository('....:Account')->getAllAccount()

 listsofuser=$em->getRepository('..:user')->getAllusers()

My question, is how to put the two result into new object $tableResults which contains all information from the listsofaccounts and listsofusers

$tableResult=$listofAccounts+$lissofusers

Upvotes: 0

Views: 162

Answers (1)

Guillaume Fache
Guillaume Fache

Reputation: 813

I hope I understand you right, but my suggestion would be for you to use the array_merge() function, like this :

$tableResult = array_merge($listofAccounts, $listofusers);

array_merge() accepts arrays as parameters, which is what should be returned by a "getAll...()" method.

Hope this helps.

Upvotes: 1

Related Questions