PHP code example of zjkiza / sql-twig-bundle
1. Go to this page and download the library: Download zjkiza/sql-twig-bundle 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/ */
zjkiza / sql-twig-bundle example snippets
declare(strict_types=1);
return [
// other bundles
Zjk\SqlTwig\ZJKizaSqlTwigBundle::class => ['all' => true],
];
namespace App\Example;
use Zjk\SqlTwig\Contract\SqlTwigInterface;
class MyRepository {
private SqlTwigInterface $sqlTwig;
public function __construct(SqlTwigInterface $sqlTwig)
{
$this->sqlTwig = $sqlTwig;
}
public function allMedia(): array
{
return $this->sqlTwig->executeQuery('@media/all_media.sql.twig', [
'user' => true,
'ids' => ['60b16643-d5e0-468a-8823-499fcf07684a', '60b16643-d5e0-468a-8823-499fcf07684b'],
],[
'ids' => ArrayParameterType::STRING,
])->fetchAllAssociative()
}
public function withTransaction(): array
{
$result = $this->manager->transaction(
static fn (SqlTwigInterface $manager): Result => $manager->executeQuery('@query/media_id_title.sql.twig'),
TransactionIsolationLevel::READ_UNCOMMITTED
);
return $result->fetchAllAssociative();
}
}