Source Providers

Database Source

Content Source based on MySQL Database.

The Database Source feeds data from local or external MySQL Database Tables, supporting relations and dynamic filtering/ordering. Based on the multi-instance source workflow it allows connecting to multiple databases with different configurations.


Settings

The source settings determines the content structure, every time the instance is saved the structure will be regenerated.

Database Instance Configuration
SettingDescriptionRequired
DatabaseThe name of the database to which to connect to. Defaults to the site database.
TableThe table from which to create the source.
Primary KeyThe primary key of the selected table, this is specially important when using relations.
Custom ConnectionShould the connection to the database use custom connection instead of the site one.
RelationsThe list of relations and their configuration.

The following settings are common to all source instances.

Source Instance Common Settings
SettingDefaultDescription
NameDatabaseThe name that will identify this source instance.
Default Cache Time3600The default duration in seconds before the cache is renewed, set to 0 to disable caching. This setting can be overriden in each query configuration.

Content Structure

Be cautious, changing certain settings of an instance might affect it content structure and break existing content mappings.


Custom Connection

The connection to the database will use the site configuration, but if Custom Connection is enabled the settings inputs will be used instead with support for local as remote servers.

Database Instance Connection
SettingDescriptionRequired
HostThe IP or domain of the database server.
PortThe port which to use to connect to the server.
Username / PasswordThe credentials which to use to connect to the server.

Table Relations

Complex data structures typically involve several tables related between them, if that's the case you can set as many relations as needed of the type:

  • One to One, also known as BelongsTo, where a single entry relates with another single entry, e.g. Article belongs to an Author.
  • One to Many, also known as HasMany, where a single entry relates with multiple entries, e.g. Article is assigned to many Categories.
Database Instance Relations
SettingDescriptionRequired
NameThe name to associate the relation with. Should be meaningfull, e.g. Author.
Relation TypeThe relation type, One to One or One to Many.
Related TableThe table that is being related with the main table.
Main Table KeyThe column key from the main table to use for the relation.
Related Table KeyThe column key from the related table to use for the relation.

MySQL Views

Relations can get complex and difficult to debug, an alternative simpler approach is to create a MySQL View with the relations solved and use that view as the main table.


Content Queries

For every source instance the following content queries will be made available as Dynamic Content option.

Record Query

Fetches a single record from the table and resolves to a dynamically generated record type based on the table schema.

Database Record Query
SettingDefaultDescription
Filters[]The list of filter conditions applied to the query.
Ordering[]The list of ordering conditions applied to the query.
RandomfalseShould the ordering be randomized ignoring any ordering condition.
Start1The offset applied to the query.
Cache3600The duration in seconds before the cache is invalidated and the query re-executed.

Records Query

Fetches records from the table and resolves to a dynamically generated list of record type based on the table schema.

Database Records Query
SettingDefaultDescription
Filters[]The list of filter conditions applied to the query.
Ordering[]The list of ordering conditions applied to the query.
RandomfalseShould the ordering be randomized ignoring any ordering condition.
Start1The offset applied to the query.
Quantity20The limit applied to the query.
Cache3600The duration in seconds before the cache is invalidated and the query re-executed.
Previous
RSS