I have two table say Project and Project allocation.
If we create form of Project object we can also get all project allocation by default.
class projectType extends AbstractType {
......
->add('projectAllocation', 'collection',
array(
'type' => new \ProjectBundle\Form\Type\projectAllocationType(),
'allow_add' => true, 'allow_delete' => true,
'prototype' => true,))
...
Simlarly we have projectAllocationType
form.
Now in this case all project allocation records will be retrieved in the form.
Can we have something like project allocation record which satisfy few condition like between some date etc.
Basically it is like search and edit if we have lot of collection record
Any suggestion will be helpful to implement same.
Edited
$qb=$repository->createQueryBuilder("p")
//->from('Project', 'p')
->leftJoin('p.billingItems', 'b')
->leftJoin('b.invoice', 'inv')
->where('p.projectId = ?1')
->orderBy('p.name', 'ASC')
->setParameter(1, $projectId);
if($invoice){
$qb->andWhere('inv.invoiceId='.$invoice);
// $queryString .= "and inv.invoiceId=".$invoice;
}
$query->getSql() query is proper.
SELECT p0_.project_id AS project_id0, p0_.name AS name1, b1_.billing_items_id
FROM project p0_
LEFT JOIN billing_items b1_ ON p0_.project_id = b1_.project_id
LEFT JOIN invoice i2_ ON b1_.invoice_id = i2_.invoice_id
WHERE p0_.project_id =171
AND i2_.invoice_id =3
ORDER BY p0_.name ASC
LIMIT 0 , 30
Here billing_items_id
manually added while directly executing query on DB which displayed proper result.
But Doctrine
query project
object contains all billing items. I need only items which equal to invoice
.