PHP Classes

File: documentation/en/Models.md

Recommend this page to a friend!
  Classes of Fernando Val   Springy   documentation/en/Models.md   Download  
File: documentation/en/Models.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Springy
Microframework for Web application development
Author: By
Last change:
Date: 7 years ago
Size: 1,148 bytes
 

Contents

Class file image Download

Models

About

Model is part of MVC architecture of the framework. They are objects representing business data, rules and logic.

Creating Models

You can create model classes by extending Springy\\Model or its child classes.

The script files of your models must be located in the classes directory.

The names of the files must be correspondent to the name of the model, followed by the extension .php.

The follow example show a simple model code:

use Springy\Model;

class MyModel extends Model
{
    /// The table name
    protected $tableName = 'users';
    /// The primary key column
    protected $primaryKey = 'id';
    /// The name of the column where the insert datetime is saved
    protected $insertDateColumn = 'created_at';
    /// The name of the column to set a logic exclusion
    protected $deletedColumn = 'deleted';
    /// Columns who can be updated by application
    protected $writableColumns = ['first_name', 'last_name', 'email'];
}