Search by

artemeon / database

artemeon

Database access layer for the AGP@ARTEMEON software suite.

Package info

github.com/artemeon/database

Homepage

pkg:composer/artemeon/database

Statistics

Installs: 103 767

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 8

5.1.0 2026-09-07 11:17 UTC

README

The following matrix shows the Branch to AGP version mapping

Branch AGP
4.0.x 11.0
3.0.x 10.0
0.2.x 9.0

Query builder

Connection::createQueryBuilder() returns a Doctrine DBAL QueryBuilder whose queries run through the existing Artemeon connection (same driver, same transaction):

$qb = $connection->createQueryBuilder();
$rows = $qb
    ->select('title', 'year')
    ->from('books')
    ->where($qb->expr()->in('id', ':ids'))
    ->setParameter('ids', ['b-1', 'b-3'], ArrayParameterType::STRING)
    ->setMaxResults(10)
    ->executeQuery()
    ->fetchAllAssociative();

Works with the mysqli, postgres and sqlite3 drivers. lastInsertId() is not supported.

Parameters are passed to the database as they are, like with the fetch*() methods. Unlike getPArray() and executeStatement(), the query builder does not HTML-encode them. Data written with HTML encoding (e.g. by an ORM on top of this library) therefore only matches if you encode the value the same way yourself:

$encode = static fn (string $value): string =>
    htmlspecialchars(html_entity_decode($value, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8');

$qb->where('title = :title')->setParameter('title', $encode('A & B')); // matches 'A & B'

This is the encoding getPArray() and executeStatement() apply. Also use it when writing to columns that are read or rendered as encoded text, and for values passed to expr()->literal(). Leave numbers, IDs and booleans as they are. Results are returned as stored, without decoding. A runnable demo lives in examples/query_builder_sqlite.php.