PHP code example of eltharin / autoqb
1. Go to this page and download the library: Download eltharin/autoqb library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eltharin / autoqb example snippets
use Eltharin\AutomaticQueryBuilderBundle\Repository\AutoQbRepository;
class MyEntityRepository extends ServiceEntityRepository
{
use AutoQbRepository;
....
}
$dql = $myRepository->getDQL();
$dql = $myRepository->getDQL((new DqlOptions)->with('classtest1__classtest2'));
$dql = $myRepository->getDQL((new DqlOptions)->with('classtest1__classtest2__classtest3'));
#[ORM\ManyToOne()]
#[ORM\JoinColumn(nullable: false)]
#[AutoQbField(autoLink: true)]
private ?ClassTest4 $classtest4 = null;
$dql = $myRepository->getDQL();
#[ORM\ManyToOne()]
#[ORM\JoinColumn(nullable: false)]
#[AutoQbField(autoLink: true, joinType: 'inner')]
private ?ClassTest4 $classtest4 = null;
$dql = $myRepository->getDQL();
#[ORM\ManyToOne()]
#[ORM\JoinColumn(nullable: false)]
#[AutoQbField(whenAlias: 'classtest2', autoLink: true)]
private ?ClassTest3 $classtest3 = null;
$dql = $class1Repository->getDQL((new DqlOptions)->with('classtest1__classtest2'));
$dql = $class2Repository->getDQL();
#[ORM\ManyToOne()]
#[ORM\JoinColumn(nullable: false)]
#[AutoQbField(relationAlias: 'classtest2All')]
#[AutoQbField(conditionType: 'WITH', condition: '##alias##.visible = 1')]
private ?ClassTest2 $classtest2 = null;
$dql = $class1Repository->getDQL((new DqlOptions)->with('classtest1__classtest2'));
$dql = $class1Repository->getDQL((new DqlOptions)->with('classtest1__classtest2All'));
#[ORM\ManyToOne()]
#[ORM\JoinColumn(nullable: false)]
#[AutoQbField(indexBy: 'idForIndexBy')]
private ?ClassTest3 $classtest3 = null;
#[ORM\ManyToOne()]
#[ORM\JoinColumn(nullable: false)]
#[AutoQbField(callback: 'myCallbackInRepository')]
private ?ClassTest4 $classtest4 = null;
public function myCallbackInRepository(QueryBuilder $qb, AssociationMapping $assoc, AutoQbField $propertyAttribute, string $alias, string $subAlias, $from = [], $count = 0, ?array $with = [])
{
$qb->andWhere($alias . '.property = :something')->setParameter('something', 'something');
}