Getting started


Views and routes


SQL queries

Sessions and security




Data types

The core of MV based on data types for models and forms, that can be both typical for programming (string, integer, float etc), or special ones for more convenient operation (files, images, arrays of images, groups). All data types have their fields in SQL table except for "many_to_many" type (for this type a special linking table is created), and also "many_to_one" which shows the number of records of other model, taken by foreign key. The types can have a special attributes that specify particular settings for each field in model.

To create a field in a model or form you need to fill an array with 3 required parameters and one optional:

  1. Text field name
  2. Data type
  3. Field name in SQL table
  4. An array of additional parameters
array("Activation", "bool", "active", array("on_create" => true))

array("Name", "char", "name", array("required" => true))

array("Album", "enum", "album", array("foreign_key" => "Albums", "empty_value" => true))

array("Rating", "float", "rating")

array("Position", "order", "order")

array("Image", "image", "image", array("required" => true))

Models and views

The main components of MV are models - classes for data management in SQL tables and views (templates) - PHP files for HTML code generation. The model consists of several fields that act within the model as objects to interact with each other and with other models. Based on model fields the Admin Interface will be automatically created.

class News extends Model
    protected $name = "News";

    protected $model_elements = array(
        array("Activation", "bool", "active", array("on_create" => true)),
        array("Date", "date", "date", array("required" => true)),
        array("Name", "char", "name", array("required" => true)),
        array("News", "text", "content", array("rich_text" => true)),
        array("Comments", "many_to_one", "comments", array("related_model" => "Comments"))

    public function display()
        $rows = $this -> select(array("active" => 1, "order->desc" => "date"));
        $html = "";

        foreach($rows as $row)
            $html .= "<h2>".$row["name"]."</h2>";
            $html .= "<p>Date: <span>".I18n :: firmatDate($row["date"])."</span></p>";
            $html .= "<p>".$row["content"]."</p>";  

        return $html;

PHP is a template generator in MV architecture, template files are located in a special folder and included as a result of URL processing by Router. The search of required records in SQL tables and calls of model methods to display data are usually located in the template.

<div id="content">
    <h1><? echo $news -> name; ?></h1>
    <p class="date"><? echo I18n :: formatDate($news -> date); ?></p>
    <? echo $news -> content; ?>


Including of required templates (views) is performed with the help of Routing, based on the passed URL. The requested URL is divided into parts and analyzed by the Router after that a proper template will be included. When analyzing the URL regular expressions aren't applied, to increase performance a comparison with the standard templates will go as described in General principles of templates section.

The template is included in any case, even if no match was found, a default template will be included, from which it is possible to call 404 error template.

"contacts/" => "view-contacts.php",

"user/login/" => "client/view-login.php",

"news/*/" => "view-news.php"


Forms are created based on data types very similar to models. Also, it is possible to create forms based on launched models, using the already created structure of fields. MV has tools to validate form fields, display fields and their errors, construct messages, quickly create records in SQL tables based on form data.

$form_news = new Form("News");

$fields = array(
    array("Name", "char", "name", array("required" => true)),
    array("Email", "email", "email", array("required" => true)),
    array("Phone", "phone", "phone"),
    array("Question", "text", "question", array("required" => true))

$form_contact = new Form($fields);

<form method="post" action="">
        <? echo $form_contact -> display(); ?>
    <div><input type="submit" value="Send" /></div>

Admin panel

There is a component of MV named Admin Panel that automatically creates the interface for model data management. All active models have their own sections in Admin Panel where it is possible to create, edit and delete records.

The following components are included in Admin Panel:

  • Lists of all records of the model
  • Records management (CRUD)
  • Deleting in a recycle bin with an option to restore
  • Search (filtering) of records on all fields
  • Bulk operations with records
  • Change history of all fields for each record
  • Administrators with different levels of rights
  • Operations history of administrators
  • File manager