1

I am working on a project. I am using symfony2 with XAMPP with PHP version of 5.5.19. I have three tables that have relationship ..

Here are the tables :

table_name : transaction_tbl 
- transaction_id
-filename
-filepath
-sender
-doctype_id

table_name : doctype_tbl
-doctype_id
- doctype
-name
-description

table_name : transaction_details

- details_id
-ref_numbers
-amount
-transaction_id

what I want to do is to join the three tables so I can get the doctype with its details. Meaning need to join also the transaction and the transaction details. I don't know how to do it. Can somebody help ?

UPDATE

I forgot to say that I am using doctrine query builder.

2 Answers 2

2
$qb->select('DISTINCT m')
->from('MessageBundle:AssignmentUser', 'au')
->innerJoin('au.assignment', 'a', 'WITH', 'a.status = (:assigned)')
->innerJoin('au.user', 'u')
->innerJoin('a.message', 'm')
->where('u.id = (:user_id)')
->setParameter('assigned', 'assigned')
->setParameter('user_id', $yourSpecificUserId)
->orderBy("m.createdAt", "desc");

See Symfony2 / Doctrine multiple joins returns error for details.

Sign up to request clarification or add additional context in comments.

1 Comment

why does it give method for object does not exist?
1

The best way is probably to use Doctrine ORM, define your entities and their relations with annotations, and use Doctrine QueryBuilder to interact with your data.

See http://symfony.com/doc/current/book/doctrine.html.

2 Comments

I am using doctrine query builder.. Can you give me example on how should I do it? I am new to this one. :)
Ok that was an important piece of information missing :-) See @kailash-sharma answer for an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.