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
  • NameSpace : dao
  • Are located in [root]app/dao
DTO - Data Transition Object
  • NameSpace : dao\dto
  • Are located in [root]app/dao/dto
        <td>SQL Row Object (fetch_object)</td>
        <td>Array of dto's</td>
        <td>SQL Result</td>
DVC Term Equivalent Object

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

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);