MV framework logo
  • Architecture
  • Philosophy
  • Admin panel
  • Support
  • Feedback
Documentation
Download .zip version 3.2.0 from 25.12.2024
  • Architecture
  • Philosophy
  • Admin panel
  • Support
  • Feedback
Getting started
  • Installation and launch
  • Folder structure
  • Launching a simple website
  • Pre-installed models
  • SQLite getting started
  • System settings
  • Migrations
  • Debugging
Models
  • General principles of models
  • Data types
  • Model setup
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Managing simple models
  • Additional features
Templates and routing
  • General principles of templates
  • Router object
  • MV object
  • Create a new template
  • Output of data in template
  • Record object
  • Files and images
  • Date and time
  • Redirects and http
  • Sending email
  • Special methods
Forms
  • Creating forms
  • Setting up form fields
  • Validating form fields
  • Form security
  • Working with form data
  • Using data from models
  • Form methods
SQL queries
  • Query builder
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
Additional
  • AJAX
  • Plugins
  • Caching
  • Security
  • Admin panel add-ons
Documentation
Getting started
  • Installation and launch
  • Folder structure
  • Launching a simple website
  • Pre-installed models
  • SQLite getting started
  • System settings
  • Migrations
  • Debugging
Models
  • General principles of models
  • Data types
  • Model setup
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Managing simple models
  • Additional features
Templates and routing
  • General principles of templates
  • Router object
  • MV object
  • Create a new template
  • Output of data in template
  • Record object
  • Files and images
  • Date and time
  • Redirects and http
  • Sending email
  • Special methods
Forms
  • Creating forms
  • Setting up form fields
  • Validating form fields
  • Form security
  • Working with form data
  • Using data from models
  • Form methods
SQL queries
  • Query builder
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
Additional
  • AJAX
  • Plugins
  • Caching
  • Security
  • Admin panel add-ons
MV tracker

Simple models

Simple models are used to store unique data and differ from regular models in the following ways:

  1. The model class is inherited from the ModelSimple class.
  2. The model SQL table contains only 2 fields, key and value, where key is a string primary key and value is a text field.
  3. When creating a model, it is not necessary to enter key values ​​into the table, MV does this automatically.

Otherwise, the creation of a simple model follows the principles described in the section General principles of models and is configured in the same way as described in the section Configuring a model.

class Options extends ModelSimple
{
    protected $name = 'Settings';
    
    protected $model_elements = [
        ['Show banner', 'enum', 'promo', ['empty_value' => 'Always',
                                          'values_list' => [
                                              'morning' => 'In the morning',
                                              'evening' => 'In the evening',
                                              'night' => 'At night'
                                           ]]],        
        ['Date of accepting applications', 'date_time', 'work_date'],
        ['Price list', 'file', 'price_file'],
        ['Image at the top', 'image', 'top_image'],
        ['Image gallery', 'multi_images', 'gallery']
    ];
}

To run the simple model, as with a regular model, you need to:

  1. Create a class with dataype fields.
  2. Add the model class name to the config/models.php file.
  3. Run migration from console or admin panel.

The process of extracting data from simple models into templates is described in the section Outputting data in a template.

Previous section

Model setup

Next section

Foreign keys
MV workshop banner
MV tracker

© 2014-2025, MV framework team

MV tracker project Github