API Reference

Namespaces live under Pionia\Porm\. Global helpers are defined in src/Pionia/Utils/helpers.php.

Helpers

HelperSignatureReturns
table()table(?string $name, ?string $alias, null|string|array $using)Porm
db()alias of table()Porm
connectionManager()ConnectionManager

Pionia\Porm\Core\Porm

Created via table(). Combines table-level CRUD with entry into builder modes.

Configuration chain (non-executing)

MethodDescription
columns(string|array)SELECT list; supports col(alias) and [Int] casts
where(array)Merge WHERE (table-level)
filter(?array $where)Builder
join()Join
useIndex(string)MySQL index hint
using(null|string|array|Connection)Switch connection for this instance

Table-level execution

MethodReturnsNotes
get(int|array|string, ?string $idField)?objectPK or WHERE
getOrThrow(...)objectthrows NotFoundException
first(?int, ?array, string $pk)object|array|null
all(?array $where)array
has(int|string|array, ?string $pk)bool
save(array, bool $returnRow = true)object
saveAll(array, ?bool $returning)array|PDOStatement|null
saveOrUpdate(array, string $pk, bool $nativeUpsert = true)object|arraynative upsert when PK present
update(array $data, array $where)PDOStatement
delete(array $where)PDOStatement
deleteById(int|string)PDOStatement
deleteAll(array)alias of delete
random(?int, ?array, string $pk, string $strategy)object|arraysample | native
chunk(int, callable, ?array, string $pk)void
explain(?array $where)arrayEXPLAIN plan
count(?string $col, ?array $where)?int
sum(string $col, ?array $where)?string
avg(string $col, ?array $where)?string
max(string $col, ?array $where)?string
min(string $col, ?array $where)?string
raw(string $sql, ?array $params)object|array
inTransaction(callable)void
lastQuery()?stringreadable SQL (inlined)
getDatabase()->lastPrepared()?array[statement, map] with placeholders
lastSaved()?stringinsert ID
info()arrayconnection meta
getDatabase()Piqllow-level

Pionia\Porm\Database\Builders\Builder

Returned by filter().

MethodDescription
where(col, value) / where(col, op, value) / where(array)Fluent or array conditions (AND)
orWhere(...)OR group with prior conditions
whereEquals, whereIs, whereNotEqualEquality helpers
whereStartsWith, whereEndsWith, whereIncludes, whereNotIncludesLIKE helpers
whereGreaterThan, whereLessThan, …Comparison helpers
whereIn, whereNotIn, whereNull, whereNotNull, whereBetweenCommon filters
orderBy(string|array)ORDER BY
group(string|array)GROUP BY
having(array)HAVING
limit(int)LIMIT
startAt(int)OFFSET (requires limit)
match($columns, $keyword, $mode)FULLTEXT
get(array|int)Single row
first()First row
all()All rows
count(?string, ?array)COUNT
sum, avg, max, minAggregates

Pionia\Porm\Database\Builders\Join

Returned by join().

MethodDescription
inner / innerJoin($table, $on, $alias?)INNER JOIN
left / leftJoin($table, $on, $alias?)LEFT JOIN
right / rightJoin($table, $on, $alias?)RIGHT JOIN
full / fullJoin($table, $on, $alias?)FULL JOIN
filter(?array)Merge array WHERE (sugar)
where(...)Fluent / array WHERE
get(), first()Single joined row
all()Rows
count(?string, ?array)COUNT with joins
random(?int, ?array)Random joined rows
orderBy, group, having, limit, startAtFrom FilterTrait
getJoins()Medoo-style join array (debug)

ON helpers: Pionia\Porm\Database\Builders\JoinOnmap(), maps(), using(), expression(), columns().

Full guide: Relationships & joins.

Pionia\Porm\Database\Builders\JoinLoader

MethodDescription
eager($parents, $parentFk, $relatedTable, $relatedPk = 'id', $attachAs = 'related', $connection = null)Attach related rows in one WHERE IN query

Pionia\Porm\Database\Builders\Where

Where::builder()->and()->or()->build() — nested AND/OR. See WHERE DSL.

Pionia\Porm\Database\Aggregation\Agg

Agg::builder()->…->build() — expressions for WHERE/HAVING (like, between, compare, etc.). See Aggregation.

Pionia\Porm\PaginationCore

MethodDescription
__construct(?array $req, string $table, ?int $limit, ?int $offset, ?string $db, ?string $alias)
columns(string|array)SELECT list
where(array)Base WHERE
init(callable)Customize Builder/Join
paginate(?array $where, ?array $joins)Page payload
paginateApproximate(?array $where, int $countCacheTtl = 60)Cached total count; sets approximate_count

Pionia\Porm\ConnectionManager

MethodDescription
connection(null|string|array $name)Pooled Connection
register(string, Connection)Inject connection
disconnect(?string)Clear pool
has(string)Pool contains name

Pionia\Porm\Driver\Connection

MethodDescription
Connection::connect($name)Via manager
Connection::open(array $config)Standalone instance

Pionia\Porm\Core\Piql

Low-level SQL engine (Medoo-compatible). Access via $porm->getDatabase(). Key methods: Piql::raw(string, array), upsert(), lastPrepared().

Exceptions

ClassWhen
Pionia\Porm\Exceptions\BaseDatabaseExceptionQuery errors
Pionia\Exceptions\DatabaseExceptionWrapper / domain
Pionia\Exceptions\NotFoundExceptiongetOrThrow()
Pionia\Exceptions\ValidationExceptionHTTP 422 — missing/invalid fields in GenericService

Source layout (framework)

PathRole
src/Pionia/Porm/Core/Porm.phpFacade
src/Pionia/Porm/Core/Piql.phpSQL engine
src/Pionia/Porm/Database/Utils/TableLevelQueryTrait.phpCRUD traits
src/Pionia/Porm/Database/Aggregation/AggregateTrait.phpAggregates
src/Pionia/Porm/Database/Utils/FilterTrait.phpORDER/LIMIT
src/Pionia/Porm/PaginationCore.phpPagination
src/Pionia/Porm/ConnectionManager.phpPooling

Prose guides: Database index.