On this page
dbxDB, DD and FD form the database of dbxapp. Technical code does not work directly with PDO and normally does not know a physical table name. He uses a DD reference such as dbxWorkflow|workflowDefinition.
Understand the data flow at a glance
The DD defines the intended state; fields or indexes may still be missing from the physical table.
dbxDD displayed and applied the confirmed differences. Domain access still goes through dbxDB.
Classification in the Golden Path
Mandatory module manual shows the same data pipeline in a complete module. This chapter is the in-depth reference for queries, writing, DD/FD and schema matching.
Interaction
| Building block | Responsibility | Typical location |
|---|---|---|
| dbxDB | Reading, Writing, Rights, Owner Filter, Trace and DB Abstraction | dbx/include/dbxDB.class.php |
| dbxDD | Read DD model and synchronize DD and physical DB | dbx/include/dbxDD.class.php |
| DD | Table, fields, indices, rights, defaults, validation | dbx/modules/{modul}/dd/*.dd.php |
| FD | Form view on DD fields: Order, template, label, options | dbx/modules/{modul}/fd/*.fd.php |
An explicit reference consists of module and DD name:
Without a module prefix, dbxapp searches first in the active module and then in the core module dbx. In reusable technical code, the explicit reference is usually more understandable and prevents name collisions.
dbxDB and dbxDD as stable facades
dbxDB is great because connection, DD resolution, rights, owner filter, transactions, trace, error and DB abstraction must work the same in each module. dbxDD This facade is extended by schema, backup, restore and transfer processes.
Classes are not divided by number of lines. An internal extraction is only useful if an independent responsibility is proven with tests and compatible public API. Domain modules continue to use dbxDB/dbxDD as the only entry and know no internal helpers.
A complete DD
The following pattern corresponds to the DD format exported by dbxapp. Table, fields and indexes are directly in the sections TABLE, FIELDS and INDEXES. Each field is fully visible and is subsequently $fields[] = $field attached. Local $addField-Closures or other auxiliary abstractions do not belong in a DD.
Binding real examples are dbx/modules/dbx/dd/dbxMissing.dd.php and the two DDs of the myInvoicesreference modules.
Important table attributes
| Attribute | Meaning |
|---|---|
| Servers | Configured DB server or module related SQLite file |
| Table table | Physical table name |
| Primary | primary key; standard is: id |
| Language | 0 neutral, voice code fixed or * Dynamics |
| Autosync | Table may be synchronized from the DD |
| Trash | Recycle basket/trace behavior of the table |
| traceability | Changes are logged traceably via the DB pipeline |
| read/create/update/delete | Group rights for each operation |
| read owner/update_owner | Owner-based rights; dbxDB complements the owner filter |
Owner, timestamp and Trash are not mandatory for every table. However, they should be used together and explicitly if property, traceability or soft delete are technically needed.
Are create date, create uid, Owner, update date and update uid present in the DD, sets dbxDB it automatically. A domain module must not reconstruct this logic in the form or before insert(), Update() or save() Reconstruction.
Local service per DD
$table['server' is the delivered standard, not a global determination for the whole system. An installation can be any DD in config.local.php Bind individually to a DB3 file or an active SQL server. dbxDB resolves this binding centrally; Domain modules remain unchanged.
Invalid explicit bindings are rejected and do not fall unnoticed to the DD standard. Installation, migration, backup and rollback are under Installation, Updates and DD Service Connections Mandatory description.
Field attributes
| Attribute | Meaning |
|---|---|
| Name, Type, length | Database field and data type |
| Index | e.g. B. PRI, UNI or MUL |
| Description | Default for new or empty records |
| Rules | Validator rules, e.g. B. int, Parameters, email, min min, max |
| tpl | Standard field template for dbxForm |
| Options | Selection values, usually value=Label&wert2=Label2 |
| Data | template data, e.g. B. rows=6 |
| converter | Output/input conversion |
FD: a form view of the DD
The DD describes the technical data structure. A FD selects the form fields, assigns them and can overwrite display properties. Thus, edit, search and quick form can represent the same DD differently.
Language versions and messages
A FD contains visible labels, options, placeholders and messages. Therefore, there is a German, English and Spanish version for each FD:
| Language | File | save success | save error’ |
|---|---|---|---|
| German | task-form.fd.php or task-form_de.fd.php | Data was stored | Data could not be stored |
| English | task-form_en.fd.php | Data was saved | Data could not be saved |
| Spanish | task-form_es.fd.php | Los datos se guardaron | Los datos no se pudieron guardar |
dbxForm resolves the file via the active language, loads $fields and $messages keep both in the central FD cache. dbxReport inherits exactly the same sequence. The binding key is called save success; save success is only carried as a compatible alias.
A DD, on the other hand, only receives language files if there are actually separate language tables. Visible translations alone are no reason to duplicate a DD.
Options:
- Only dd put: dbxForm uses DD field information.
- dd and fd put: The FD determines the specific form view.
- Complete individual fields manually or specifically DD values with dd: use.
- For a report an own Selection-FD with dbx rwhere, dbx rsort, dbx rdesc, dbx rrows and optional dbx rselect use.
Read dbxDB
Reading a record
An integer WHERE is resolved against the primary key defined in the DD. Columns may be limited:
select1() does not provide the empty standard structure of the DD for any hit. Therefore, technical code should not only is array() Check, but also the ID:
select1() notes successful individual and blank records requestlocally. The cache key contains the canonical DD name, WHERE, column selection, rights check, and user. insert(), Update(), save() and delete() After successful writing, reject all select1()-Entries exactly this DD. Within a transaction, the cache is bypassed; Commit and rollback discard the affected server’s DD caches. The cache ends with the request and is limited to 1,000 entries.
Lists, sorting and pagination
The parameters according to $columns are: orderby, ASC|DESC, groupby, max, offset and verify access. If sorting comes from a request, the column name and direction must be checked against fixed allowlists beforehand; They are not free search values.
Safe search
Array-WHEREs validate fields against the DD and escape values centrally:
A structured form is also possible for a single LIKE field:
New request searches should use these forms. A string WHERE remains possible for existing and internally built code, but must not be created by uncontrolled concatenation of user inputs.
Counting
Write dbxDB
Automatic system fields
In insert() set dbxDB automatically:
- create date
- create uid
- Owner
- update date
- update uid
In Update() set dbxDB Automatic update date and update uid. dbxForm::save_post() uses the same dbxDBpipeline. Automatic is a key advantage of DD usage: All modules receive identical audit and owner values without managing them themselves.
Insert
insert() Delivery 1 if successful. The new ID is then read:
Update
Insert or update with save()
save() updates with existing WHERE/RID and adds otherwise. For technically complex storages, separate insert/update branches are often more readable; Used for standard forms dbxForm::save_post() internally this way.
Delete
A delete without WHERE is blocked by dbxDB. Whether a table should really be deleted, traced or treated via a domain trash is decided by the module together with the DD. Do not arbitrarily deactivate rights or trace checks.
Parameters for rights, fields, values and trace
The writing methods have infrastructure switches at the end:
In the domain module, all values normally remain 1. Calls with 0 are only intended for clearly limited system paths, such as installation, internal synchronization or already separately protected infrastructure. There are real examples of this in dbxWorkflowEngine, dbxContentLngSync and dbxShopRepository.
Tree data
For parent/child structures, select tree() Normalize folders and optional items together:
The specific CMS-DD is voice-dependent on dbxContentLng determined. The example shows the API; CMS code should use the existing resolvers.
Read the DD model
This makes sense for generators, admin tools and workflow bindings. Technical code should not dynamically guess its business logic from field definitions at every request.
Syncing DD and Database
DD-Sync is a step-by-step process. The robust pattern from the current modules resets the process and calls Applicable Until it is finished:
Available modes of use:
- Plan/check: Show differences without applying the scheme.
- reset: Reset the stored process state.
- Applicable: Use planned steps in a controlled manner.
- Force: Force only in dedicated admin/installation paths.
- sync db to dd(...): transfer or merge an existing DB structure into a DD.
DB according to DD is not a normal domain action. It belongs in Schema/Wizard tools and must then be tested as a complete, readable DD.
Database systems
dbxDB encapsulates access via PDO. Depending on configuration and PHP drivers, support includes SQLite, MySQL/MariaDB, PostgreSQL, SQL Server, Oracle, Firebird and other PDO drivers. A DD must therefore not force a SQLite-specific technical logic. Differences in schema and limits are dealt with in dbxDB/dbxDD.
Central query performance
If performance timer level on Maintenance or Details stands, measures dbxDB all central query, exec, insert and update paths. Per request, number, unique structures, repetitions, runtime, slow and failed queries are summarized. Off Details In addition, the most expensive normalized SQL structures are stored as fingerprints.
SQL comments and literal values are removed before storage; bound parameters are never logged. The threshold for a slow query is over performance timer slow query ms established. The evaluation is in the admin dashboard. As a result, optimizations are made based on actual request costs and query duplicates, instead of providing individual SQL points with a parallel measurement logic on suspicion.
The persistence is excluded from the measurement so that the performance tables do not produce recursive self-measurements. Domain modules continue to use exclusively dbxDB; Your own query loggers are not allowed.
During the first run after an extension, the Performance service additionally compares its tables with the DD fields and indices. Existing measured values are retained. Query mean values do not incorrectly include historical records without query profile as zero measurements.
Binding rules
- Use of specialised modules dbxDB, not directly PDO.
- DD is the versionable truth of the table structure.
- FD describes a form view and does not unnecessarily duplicate the data model.
- Request values are validated; Search conditions prefer Array-WHEREs.
- HTML does not belong in database methods and SQL does not belong in templates.
- verify access=0 and trace=0 are justified infrastructure exceptions.
- DD sync is completed until Finished executed and checked for errors.
- Each new table gets its own DD and a unique DD name.
- Automatic owner, user and time fields are not duplicated in the module.
Real references
- dbx/modules/dbxWorkflow/dd/workflowDefinition.dd.php: complete DD.
- dbx/modules/dbxWorkflow/fd/workflow-definition.fd.php: Form view.
- dbx/modules/dbxWorkflow/include/dbxWorkflowEngine.class.php: CRUD with array WHEREs and domain persistence.
- dbx/modules/dbxShop/include/dbxShopRepository.class.php: DD sync and extensive repository access.
- dbx/modules/dbxContent/include/dbxContentLngSync.class.php: Language-dependent DDs and controlled system write operations.
- Mandatory module manual — complete, mandatory module flow.
- DB3-MySQL-DB3 round trip — tested DB3-MySQL-DB3 transfer.