Download the PHP package ksfraser/ksf-common-db without Composer
On this page you can find all versions of the php package ksfraser/ksf-common-db. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ksfraser/ksf-common-db
More information about ksfraser/ksf-common-db
Files in ksfraser/ksf-common-db
Package ksf-common-db
Short Description Generic, transport-agnostic data dictionary + SQL query builder with a MySQL/PDO adapter (standalone) and a FrontAccounting db_* adapter. DAOs/repositories code once against DbConnectionInterface; DI picks the runtime adapter.
License GPL-3.0-or-later
Informations about the package ksf-common-db
ksf_common_db
Generic, transport-agnostic data dictionary + SQL query builder for KSF PHP
projects. DAO/Repository classes are written once against
DbConnectionInterface; DI selects the runtime adapter.
Hard rule: FA MUST use native db_* calls
Inside FrontAccounting, the adapter must translate every operation to FA's
procedural db_query() / db_fetch_assoc() / db_num_rows() /
db_num_affected_rows() / db_insert_id() / db_begin|commit|rollback_transaction()
— never a PDO handle, never raw mysqli_* connect/query.
PDO lives only in PdoDbAdapter, for the standalone/portable side (unit
tests, CLI tooling, non-FA embedding). PDO is the contract shape, not an FA
runtime transport. In production FA, always construct FaDbAdapter.
DI selection
Both implement the same DbConnectionInterface, so repository code is identical
in either context. Parameter binding accepts positional ? or named :name
placeholders: PdoDbAdapter uses native prepared statements; FaDbAdapter
escapes and inlines values (since FA has no prepared statements).
End-to-end example
Notes on namespacing / table prefixing
- The data dictionary and query builder use logical (unprefixed) table names.
FaDbAdapterprefixes physical names (tokens followingFROM|JOIN|INTO|UPDATE|TABLE) with the configuredTB_PREFvalue, skipping already-prefixed names. Backticked table names are always prefixed. - This package intentionally has a generic namespace (
ksfraser\CommonDb), NOT the FA-flavoredKsfraser\FrontAccounting\Commonused by ksf_FA_Common, because it is usable outside FA.
Heritage
FaDbAdapter is the generalized/moved implementation of the RBAC module's
Ksfraser\FrontAccounting\Rbac\Adapter\FaDbAdapter (that interface+adapter pair was
the proof of concept for this package). The TableDefinition/QueryBuilder are the
generic, parameterized rewrite of the legacy ksf_modules_common MODEL data
dictionary / clause builders.
Testing
The FA adapter is tested against in-memory stubs for the FA db_* functions
(tests/Support/fa_stubs.php); the PDO adapter is tested against in-memory SQLite.
All versions of ksf-common-db with dependencies
ext-pdo Version *