Skip to content

pushing live docs on AR and models and layout Set clarification #1008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/development/database-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
-->

# Accessing the Database
You may often want to query or update your database from within your add-on. This can be done using the [Model Service](development/services/model.md) or you can also execute SQL statements by using the legacy [Database Driver](development/legacy/database/index.md).

TIP: The Model Service is much cleaner than the legacy Database Driver. However, it also has limitations on what it can do compared to the Database Driver.
You may often want to query or update your database from within your add-on. This can be done using the [Model Service](development/services/model.md) or you can execute SQL statements by using the [Database Driver](development/legacy/database/index.md) and its [Active Record](https://docs.expressionengine.com/latest/development/legacy/database/active-record.html) class.

Each approach has its own strengths, and you can use either depending on the specific needs of your code.

Let's use a real example to show how you might access data using both methods:

Expand Down Expand Up @@ -46,7 +45,7 @@ class Memberlist extends AbstractRoute
}
```

Here is the class syntax using the legacy Database Drive:
Here is the class syntax using the Database Driver's Active Record class, which provides more portability, cleaner code, and default secuirity enhancementsa versus raw queries:

```
namespace ExpressionengineDeveloper\AmazingAddOn\Module\Tags;
Expand Down Expand Up @@ -88,4 +87,6 @@ Douglas
Richmond
```

The Database driver shines when pulling back raw data from specific sources quickly or making targeted inserts and updates. Models provide consistency and easy access to complex data. Use both as needed for fast, clean, secure interaction with the database.

This is only the beginning of how you can interact with the database through your add-on. Explore the [Model Service](development/services/model.md) and the legacy [Database Driver](development/legacy/database/index.md) to learn how to add more power to your add-on.
2 changes: 2 additions & 0 deletions docs/templates/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ You can set variables in your templates that can later be used in your layouts.

#### {layout:set}

NOTE: **Note:** {layout:set} cannot be used with {layout:set:append} and {layout:set:prepend}

**Setting** a variable works similarly to setting a string variable in a programming language, like JavaScript. The contents are set to the variable name you provide. In your template:

{layout:set name='title'}My Page Title{/layout:set}
Expand Down