A New Data Access Engine in JCB #1018
Pinned
Llewellynvdm
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Recently (two years ago) we introduced a new data access engine in Joomla Component Builder (JCB) that makes working with database data much simpler and more flexible.
This engine allows you to retrieve and store data without worrying about how it is stored internally.
Normally when working with Joomla models or database queries you must remember details such as:
With this engine, you don't need to think about any of that.
The system uses the JCB-generated table metadata to determine:
It then automatically prepares the data so that what you receive is ready to use in PHP.
Why This Exists
The Joomla model layer is powerful and still plays an important role in JCB. It provides:
However, sometimes you need more freedom.
This new engine allows you to:
So instead of Joomla enforcing permission checks through the model layer, you decide when permissions apply.
For example:
This puts full control back into the developer's hands.
Automatic Data Handling
The engine automatically handles:
If you attempt to save an incorrect datatype (for example a string where an integer is required), the engine will throw an error immediately.
This helps prevent corrupt data from ever reaching the database.
Automatic Insert or Update
The engine also provides a simple
set()workflow.When saving data:
You don't need to manually determine whether to run an
INSERTorUPDATE.Cross-Table Flexibility
For more advanced cases, the engine can also operate across multiple tables.
This is the same mechanism used in the demo component example where:
This approach makes it far easier to:
Architecture
The engine uses a factory-based container to provide access to services.
This means:
If you prefer, you can even:
This keeps the system both stable and customizable.
Automatic Code Import in JCB
When you use these examples in your project:
JCB will automatically detect the Power classes being used and import all required code into your project.
Once imported, you can edit or extend them inside the JCB Powers area.
Example: Get a Single Item
This example retrieves a single record from a table.
What happens here:
get()method retrieves the record whereid = $id.The returned value is already:
Example: Get Multiple Items
You can also retrieve multiple items in a single call.
This retrieves a collection of records matching the provided IDs.
Again, the data returned is already normalized according to the JCB table definitions.
When Should You Use This?
This engine is ideal when you want:
For standard Joomla workflows the model layer still remains excellent, but when you need something lighter and more direct, this engine provides a powerful alternative.
Beta Was this translation helpful? Give feedback.
All reactions