Reputation: 495
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.
Upvotes: 1
Views: 3915
Reputation: 356
$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.
Upvotes: 2
Reputation: 4265
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.
Upvotes: 1