Loading Please wait...
This document will give you an Overview of Zigmoyd MVC. A Zigmoyd Application is made of Three Main Components and lots of other Sub Components. these are Model, View and Controller. View is the Presentation Layer that contains several HTML tags or other presentation components with embeded PHP Codes in it. Controller holds the Business Logic of the appplication. and Model works like a Simple Configyuration file that Binds Database abstraction layers(ORM Classes) with the Controller.
- See also:
- see MVC Explained More Detailed Information on MVC
- See also:
- See more details on view Here
A View is a Simple HTML Page just like the bellow one
<div id="studentInfoBox" class="infoBox">
<span>Name: </span> <?= $name ?>
<span>Department: </span><?= $deptName ?>
</div>
Say Its stored as a file Called stdInfo.view.php .
Hope You noticed the Presece of embedded PHP Codes
<?= $name ?>
and
<?= $deptName ?>
br />which is equivalent to
<? echo $name ?>
and
<? echo $deptName ?>
respectively. (Using PHP Short Tags). Here this File is called a View which is just a Presentation Layer not much Business logic on it.
- See also:
- See more details on controller Here
Now one more Question is peeping in your mind that you can understand that the presentation layer is showing the name and department Name in HTML tags. But from where the variable(s) are Comming ? This is the Job of Controller it handles the business logics which is just a Class that extends the Project level Controller Class.
<?php
class stdInfoController extends homeController{
public function main(){
$this->name = "Student Name";
$this->deptName = "Computer Science";
}
}
?>
Here the two member variables name and deptname becomes local variables in the view when this controller renders the view.
- See also:
- See more details on model Here
In the above example we have just assigned simple values to the member variables name and deptInfo. but we can do more
in Practical situation you would like to do something like
$this->name = getNameFromDataBase()
$this->name = getNameById(1)
e.g. access value of
name
and
deptInfo
from Database in Zigmoyd Way you will do
$this->name = $this->db->Student->getNameById(1);
assuming there is a table called student and you want to fetch the value of Field `name`
where `id` = 1
Isn't it simpler enough.
$this->db->TableName->getColBySearch(Value)
- See also:
- See more details on Object-relational mapping. Here
In Zigmoyd Models acts as a Simple Configuration file like this.
<?php
class stdInfoModel extends manualModel{
public function attachOrmMap(){
parent::attachOrmMap('StudentOrm');
}
}
?>
a Model Attach's Orm Classes (Which is built by reading an ORM Map) with the Controller. and a Map Maps Tables of databases like this (schoolOrm.orm.map.php).
connection as schoolConn{
}
table std as Student{
readonly id as Id{
}
writable name as name{
required: You must enter a name of the Student
string: name of the student must be a String
}
writable dptName as DeptName{
required: Department Name must not be left Blank
string: Department Name Must be a Valid string
}
}
- See also:
- See more details on Orm Maps Here
First it Specifies which Connection File to use
schoolCon.con.ini.php
(which is shown bellow)
driver = "mysql"
database = "manual"
host = "localhost"
user = "root"
psw = "123456"
port = ""
You can provide alias names for Tables/Columns here you will access std table as Student (you dont ever need to remember the real name just remember the alias name that you haev choosen). you can also mark columns as readonly or writable. you can add
validation rules that will be checked everytime something get written to that table through the ORM Layer. So
No backdoor of invalid Data Entry even if you forget to do
form validation on tables you can have multiple Orm Maps as well as Multiple Connection Files. You just need to attach these Orm Maps with your Controller through Model. when you specify the Connection File name the Connection is automatically bound with all tables of that Orm Map. Zigmoyd parces this ORM Map file once and generates an ORM file that conrtains ORM Class(s) which is actually used in for that ORM map.
- See also:
- See more details on Orm Class(s) Here