Structure - Data (Model) View Controller

Structure - Data (Model)

The Modelling

The Data model is the layer between the database (SQL Server) and the controller

This software uses a DAO / DTO model

  • DAO - Data Access Object
  • DTO - Data Transition Object

DAO

  • NameSpace : dao
  • Are located in [root]app/dao

DTO

  • NameSpace : dao\dto
  • Are located in [root]app/dao/dto

Terms

DVC Term Equivalent Object
dto SQL Row Object (fetch_object)
dtoSet Array of dto's
result SQL Result

How to Use

  • DAO - Required
  • DTO - Optional
    • If the dto requires no customization, there is no requirement to create a dto file
  1. Create a folder for DAO files under the [root]app folder i.e. [root]app/dao
  2. Create a DAO file

Example DAO

<?php
NameSpace dao;

class users extends _dao {
    protected $_db_name = 'users';

}

Example DAO Use

$dao = new dao\users;
if ( $res = $dao->getAll()) {
    while ( $dto = $res->dto()) {
        printf( '%s<br />', $dto->name);

    }

}