MayFishPHP MVC architecture development framework. Framework workflow: loading framework files, loading parameter setting objects, initialization settings, loading project setting parameters, getting controllers and controllers, and executing controller events using the framework workflow:
Loading framework File loading parameter setting object initialization setting loading project setting parameters getting controller and controller method execute controller events
Example:
The code is as follows:
Class DefaultController extends AppController
{
Protected $ components = array ('smarty ');
/** Default event (method )*/
Public function index ()
{
$ Db_test = M ('members '); // load and instantiate a model
/** Add data */
$ Data = array (
'Title' => 'write test ',
'Body' => 'written content ',
);
$ Result = $ db_test-> create ($ data );
If (FALSE! = $ Result)
{
Dump ("
Exampel 1:
Data written successfully!
");
}
/** Add multiple data entries */
Dump ("
Exampel 2:
");
$ Data = array (
Array ('title' => 'data 1', 'body' => 'Content 1 '),
Array ('title' => 'data 2', 'body' => 'Content 2 '),
Array ('title' => 'data 3', 'body' => 'Content 3 '),
Array ('title' => 'data 4', 'body' => 'Content 4 '),
Array ('title' => 'data 5', 'body' => 'Content 5 '),
);
Foreach ($ data as $ item)
{
$ Result = $ db_test-> create ($ item );
If (FALSE! = $ Result)
{
Dump ("data". $ Item ['title']."Written successfully!
");
}
}
Dump ("
");
/** UPDATE data */
$ Data = array ('title' => 'modify data title', 'body' => 'modify data content ');
$ Result = $ db_test-> where (array ('id' => 3)-> update ($ data );
If (FALSE! = $ Result)
{
Dump ("
Exampel 3:
Data updated!
");
}
/** Delete data */
$ Result = $ db_test-> where ("id = 5")-> remove ();
If (FALSE! = $ Result)
{
Dump ("
Exampel 3:
Data deleted!
");
}
/** Execute data query and use a coherent operator */
$ Db_test-> where (array ('id' => 12, 'Action' => 1 ))
-> Order ("'id' DESC ")
-> Fields ("id, name, action ")
-> FindAll ();
$ This-> shownav ();
}
// Image processing event
Public function image ()
{
$ File = Configure: read ('app _ path'). '/yagas/K750c_small_06.jpg ';
$ Im = M ('sys ', 'image'); // load and instantiate a system model
$ Im-> th_width = 200;
$ Im-> th_height = 150;
$ Im-> thumb ($ file, null, false );
}
/** Another controller event */
Public function admin ()
{
Dump ($ this );
$ This-> shownav ();
}
/** Another controller event */
Public function info ()
{
$ This-> shownav ();
Phpinfo ();
}
/** This is an internal event and cannot be accessed from the browser address */
Private function shownav ()
{
Echo 'Access default event | access event admin | access event info ';
}
}
?>
Implementation of multiple sites in a single space
The code is as follows:
Header ('content-type: text/html; charset = utf-8 ');
Include_once ('./MayFish/init. php'); // load the MFS framework
$ Domain = $ _ SERVER ['http _ host'];
Switch ($ domain ){
Case 'S1 .xinxi169.com.cn ':
Configure: write ('app _ name', 'app ');
Configure: write ('app _ path', dirname (_ FILE _). '/app ');
Break;
Case 'www .aike8.cn ':
Case 'aike8. cn ':
Configure: write ('app _ name', 'aike8 ');
Configure: write ('app _ path', dirname (_ FILE _). '/aike8 ');
Break;
}
$ App = new application ();
$ App-> run ();
?>
Http://www.jb51.net/codes/20169.html
...