Weave Dream Frame

Source: Internet
Author: User

Reading: Functions RunApp Analysis: Function RunApp ($ct, $ac =, $directory =) $CT: Controller $ac: Action event $path: Specifies the directory in which the controller is located the execution flow of the function: 1. Illegal character filtering for $ct, $AC string , replace the non-numeric and the letter with the null 2. Find the controller corresponding directory file, require come in 3. Dynamically generated objects

function RunApp Analysis:
function RunApp ($ct, $ac = ", $directory =")
$CT: Controller
$ac: Action Events
$path: Specify the directory where the controller resides

The execution flow of the function:
1. For $ct, $AC string to do illegal character filtering, the non-numeric and the letter are replaced by empty
2. Find the controller corresponding to the directory file, require come in
3. Dynamically generated Object $instance = new $ct (), if the specified action method can be found in the class
Invokes the associated action for the object.
if (Method_exists ($instance, $action) ==true)
{

$instance->action ();
Unset ($instance);
}

We enter Http://www.example.com/ask/index.php?ct=welcome&at=index from the browser
This ask/index.php will do the Ct=welcome&at=index URL analysis, find the controller and corresponding action behavior.
This work is done by the following two lines of code. Through the unified application portal, in the control directory to find $ct php file, through the include loading and then dynamically generated class object, call the object related methods.
$CT = Request (' ct ', ' index ');//The second parameter is a default value
$ac = Request (' ac ', ' Index ');//The second parameter is a default value
RunApp ($CT, $AC);

The request function comes from the include/request.class.php file, which has a function request and a class with the same name
The purpose of this is to make it easy for the peripheral program to be called. Also a bit of feeling like in design mode in the singleton mode and Factory mode.
The function request is like a factory responsible for the production of the request class. But the whole application only needs to produce one to be enough.
It would be most appropriate for us to send him in globals. Globals equivalent to the global application storage space, session sessions, such as
The user's login information can be placed in the session, because each user's information is different.

The request class is primarily a class of variables that handle external requests. Processing the requested data to protect against hacker attacks

Weaving dream dedecms content generation static path speed optimization to speed up HTML generation

Weaving Dream Site HTML static effect, is helpful to the site SEO, but dedecms in the generation of HTML, especially when the amount of data is large when the need to generate a long time, in fact there are several solutions. The following analysis of the first, but this method, it is necessary to support the server! Weave Dream MVC Development Framework is a streamlined, mini web development framework, using this development framework can be written based on the Dream Content Management system extension functions, modules (plug-ins), and even can be separated out to develop blogs, BBS, SNS and so on.

Directory Structure Description:
|_app
|___control Controller (C)
|___model Model (M)
|___templates View Template (V)
|___libraries Class Library
|___data Configuration
|___data\helper Little Helper
|___static style, JS, picture folder
|___index.php Unified Entry File

Unified Portal Resolution Address
HTTP.//Your URL/app/index.php?ct=index&ac=save
Ct=index: Controller entry, corresponding to index.php in the directory control
If RunApp () specifies a third parameter, such as Q/A RunApp ($ct, $ac, ' admin '), description Ct=index: Controller entry, corresponding to index.php in directory Control/admin
Ac=save: Action, corresponding to the file index.php in class index in function Ac_save ()
The controller will store related functions in a file, such as the message board, you can use:
Ct=guestbook&ac={do} is unified, which makes it easy to deploy statically.

1. Controller development Instructions (control):
Basic code structure:
Class Yourctname extends Control
{
Publicfunction Ac_save ()
{

}
}
The controller can choose to inherit a base class: control, this class corresponds to the filename is/include/control.class.php, which contains the base class related operation instructions, here are a few common methods:

$control->model ();
Load a model. For example, the index.php in the question-and-answer module $this->question = $this->model (' mquestion ') is loading the mquestion model. And then we can invoke the model by $this->question the corresponding action. Implementation of data insertion, update and so on. The name of the calling class can be arbitrarily defined, but ensure there is no conflict. The file of the model is placed in the models directory.


$control->libraries ();
Loads a class. Sometimes when we need a class that doesn't exist in a system, we can load one of our own classes with this method. The exact method is the same as the model. Class is placed in the Libraries directory.

$control->helper ();
Load a small helper. Small assistants are introduced to help us to store and manage the function we need to use.
The exact method is the same as the model. The small helper is placed in the Data\helper directory.

$control->settemplate ();
$control->settemplet (); Set the template to be specified for the current operation;

$control->setvar ($k, $v); Set the variables that the template needs to parse, and make calls using {dede:var.name/} in the template.

globals[' k '] = $k;
Set the variables required by the template, in the template can be directly used in the way output (question and answer modules are basically output in this way), this method is more suitable for processing some complex data, such as arrays.

$control->getvar ($k); Get the Set template variable
$control->display (); Display the content of the template after parsing
$control->saveto (); Save content to a file

The use of the template in the controller can be referred to the dedetemplate template engine, in the company's internal development documentation for the relevant section of the template description.


Model Development Description:
Class Mtype extends Model
{
Publicfunction Get_one ()
{

}
}

The controller can choose to inherit a base class: Model, the name of the class corresponding to the/include/model.class.php, which contains the database class related instructions, there is only one method:
$model->dsql ();
Instantiate the database operation class. The use of database classes in the model can be described in the database class usage instructions


Template Tag Invocation Description:
If the controller is passed $control->setvar ($k, $v); The parameters set in this way are called by means of the label {dede:var.name/}.
If in the controller through globals[' k '] = $k, the parameter set by this way, we call through the way of the label {dede:global.name/} or directly in the way of PHP output.
More about the use of template tags can be queried on the http://help.dedecms.com/v53/.

The second method:
As we all know, the online search on the Dedecms generation speed of the method, most of the following 2:

1. Close the Sub-section
2. Turn off keyword substitution

But after my actual test, these two methods produced almost no effect, the speed is 20 seconds to generate 20 pages.

Now to the specific analysis of the problem:

The problem with table indexes is excluded first, because the Dede database has been indexed in the Data master table (Dede_archives) as the primary field. Remove the main content of the extraction efficiency problem, because the page generation process to read the page of the article data, each need to the main table and the schedule Select to obtain the ID value of the unique data content, the efficiency of this SQL statement by running the SQL statement test directly in MySQL, the execution time is very short, So this is not the biggest bottleneck.

Finally in the page generation process, we found that the program executes several times the main table (dede_archives) query, and take out a set of complex query criteria data, the query efficiency is very low, the original is it in the impact of efficiency! Through debug tracking, we locate the key to the problem, The culprit is the arclist tag in the template. Arclist tags are a lot of people like to use the label, because it is more flexible, can be removed from the data hot, up-to-date, related to various types of articles list, but the arclist tag every time with a big push search conditions to the main table query, in fact, for a large number of articles at once, If you use the same template, the Arclist query operation on the database is simply a mechanical repetition, and it takes a lot of time to be absolutely unworthy.

Weave Dream Frame

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.