<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
runopencode / query-resources-loader-bundle example snippets
declare(strict_types=1);
namespace App\Repository;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Types;
final readonly class MyReportingRepository
{
public function __construct(private Connection $connection) { }
public function getInvoicingReport(\DateTimeInterface $from): iterable
{
$sql = 'SELECT
field_1.T as f1,
field_2.T as f2,
...
field_57.X as f57,
...
field_n.N as fn
FROM
table_name T
INNER JOIN table_name_2 T2 ON (T.id = T2.t1_id)
INNER JOIN table_name_3 T3 ON (T2.id = T3.t2_id)
....
[More joins]
WHERE
T.create_at >= :from
[A lot of where statements and so on...]
';
return $this->connection->execute($sql, [
'from' => $from
], [
'from' => Types::DATE_IMMUTABLE
]);
}
}
declare(strict_types=1);
namespace App\Repository;
use RunOpenCode\Bundle\QueryResourcesLoader\Contract\QueryResourcesLoaderInterface;
use RunOpenCode\Bundle\QueryResourcesLoader\Executor\Dbal\DbalParameters;
final readonly class MyReportingRepository
{
public function __construct(private QueryResourcesLoaderInterface $loader) { }
public function getInvoicingReport(\DateTimeInterface $from): iterable
{
return $this->loader->execute('invoicing_report.sql', DbalParameters::create()->dateTimeImmutable('from', $from));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.