I have the A
table with a OneToMany
relation to the B
table.
The A
table is small, has 10 records.
The B
table has N records for each record in the A
table.
From X to X minutes a script is executed that exports the 50 new records from the B
table (for each record in the A
table) to a txt
file, for example: A
table has 10 registers, then the system looks in the B
table for the 50 new records for each record in the A
table, in this case it will be 10x50, then it will be exported to the txt
500 records file.
For this I made a innerjoin
in the repository:
class AppsRepository extends EntityRepository
{
public function findNewClients()
{
$qb = $this->createQueryBuilder('a');
$qb
->innerJoin('AppBundle\Entity\Clients', 'b', 'WITH', 'b.appId = a.id')
->where('b.proccessed is null')
;
return $qb->getQuery()->getResult();
}
}
I need to limit the innerjoin
to return only 50 records for each record in the A
table as explained above.