sanpi/pomm-template-query

dev-master 2015-07-21 11:04 UTC

README

Because one programming language per file is enough.

Installation

composer require sanpi/pomm-template-query

Configuration

Use the new session builder and specify the template directory in pomm configuration:

new Pomm([
    'pomm_db1' => [
        'dsn' => …,
        'class:session_builder' => '\Sanpi\PommProject\TemplateQuery\SessionBuilder',
        'dir:template' => __DIR__ . '/sql/',
    ],
]);

Use

Instead of loading a query, you specify an alias:

$pomm['pomm_db1']->getTemplateQuery('long_query')
    ->execute([2]);

Now pomm searches a file in dir:template directory named long_query.sql.

You can make some replacement before executing the query. This is usefull with the model manager:

$pomm['pomm_db1']->getTemplateQuery('long_query_parameter')
    ->setParameters([
        ':projection' => $this->createProjection(),
    ])
    ->execute([2]);