------------------------------------------ (Writing code is not lonely_Xiao Xiaodai)
I wrote a website using Onthink. It has not been launched yet. It has some incomplete functions. It has not exerted its power and expansion at all, and it is slightly lame in various places.
However, its powerful data table control is still missing. In view of this, it enters the world of thinphp3.2.2 based development. . .
Day 1: Complete the preface, basics, configuration, architecture, and routing reading of the manual.
Complete the controller model reading on the second day About the appendix reading
The following is the reading transcript
******************************************************
use indicates what namespace is introduced for direct reference
The naming method of the function uses lowercase letters and underscores
The naming of the method uses lowercase letters and underscores The underscore represents (general private method)
A function or method starting with a double underscore As a magic method __call
Develop a good habit of using the I function to obtain input variables;
If you encounter problems after updating or changing the environment, the first problem is to clear the Runtime directory;
Conventional configuration application configuration mode configuration debugging configuration status configuration module configuration
Conventional configuration ThinkPHP/Conf/convention.php application configuration is an expansion based on conventional configuration
Application/Common/Conf/config.php is a common configuration file that will be loaded before calling all modules
The optional mode configuration is added in the application configuration folder The file config_application name.php that is run only when running this mode
When debugging mode is turned on, ThinkPHP/Conf/debug.php and the application debugging configuration file Application under the
status configuration are manually separated
Module configuration Application/current module name/ Conf/config.php
Read the configuration file
After defining the configuration file, all use the C method provided by the system (you can use Config) to read or set
Configuration parameter names cannot contain '.' and special characters, allowed letters , numbers and underlines C method can read two-dimensional
Configuration configuration parameters are globally valid Parameter values configured through c are currently valid and will not be written to the database
URL details pathinfo mode description
serverName/index.php (or other applications Entry file)/Module/Controller/Operation/[Parameter name/Parameter value...]
Public configuration file config.php Public function file function.php can load the path into common_path
Configure in the entry file, if After defining the Application, there is no need to load the Application
3.2.2 The modules and controllers written in the entry file can be automatically generated by default. If you want to generate more controllers, use the BUILD_CONTROLLER_LIST constant
// Bind the Admin module to the current entry file
define('BIND_MODULE','Admin');
define('BUILD_CONTROLLER_LIST ',' Index, User, Menu ');
The method of calling the ThinkBulid class manually to generate the model class ThinkBuild :: Buildmodel
(' admin ',' role '); Used to be called by other modules or not accessible), the default configuration
prohibits access to the Common module and Runtime module (the Runtime directory is the default runtime directory), we can add other
list of prohibited access modules:
'MODULE_DENY_LIST' => array('Common','Runtime','Api'),
Set access list
Allow access list and default module
'MODULE_ALLOW_LIST' => array('Home','Admin','User') ,'DEFAULT_MODULE' Single module design is to turn off multi-module access MULTI_MODOULE=> 'm'] = 'Home';
define('APP_PATH','./Application/');require './ThinkPHP/ThinkPHP.php';
After binding http://serverName/index.php/Home /Index/index becomes , etc. Different model layers create Model, Logic, sercive
When calling, it is very convenient to use the D method to call D('User','Logic');//instantiate UserLogic D('User') is instantiated
UserModel.
Change the system's default view layer DEFAULT_V_LAYER=>'Mobile'; use the T function to obtain templates for non-default view layer directories.
The core controller of the Controller layer is completed in the App class inside the system
Event/UserEvent//It is used for user event response operations. Controller is responsible for external responses. Event is responsible for internal event responses, and can only be used in Internal call A('User','Event');
CBD model
Core(core)+Behavior(behavior)+Driver(driver)
Driver(driver)
3.2 has further strengthened the driver design in the architectural design, replacing Extended the previous engine and mode, and improved the behavior design
The design makes the overall framework more flexible, and because the driver-oriented design idea is adopted in the functional class libraries that need to write data, the new framework can easily meet the needs of distributed deployment, and the support for cloud platforms can Easier to implement.
Behavior
Behavior is a relatively abstract concept, and behaviors will occur in various locations.
Some behaviors are before the application is executed, and some are after the template is output. We use the position of these behaviors as tags (bits), which can also be used as hooks. When the application runs to this tag, it will be intercepted In this way, related behaviors are uniformly executed, similar to the concept of "aspect" in AOP programming. Binding related behaviors to a certain tag becomes an AOP-like programming idea.
Tag bit
The tag function is used to set a certain tag bit. It can be passed in and only accepts one parameter. If you need to pass in multiple parameters, please use an array. ThinkHook::listen('my_tag');
Behavior definition is required. Define the execution entry method run. Due to the influence of the calling mechanism of the behavior, where does the call return?
Behavior Binding After the behavior is defined, it needs to be defined to a certain label to take effect, otherwise it will not be executed. The behavior and tag location need to be defined in the tags.php file of the application's behavior definition file.
return array( 'Tag name 1'=>array('Behavior name 1',''Behavior name 2',...), 'Tag name return array( . Name 2',...), );
Version 3.2.1 or above allows you to set the corresponding class library not to use the namespace.
Configuration file 'APP_USE_NAMESPACE' => false (still required when inheriting and calling system classes)
In version 3.2, instantiate PHP's built-in class library or third-party classes that are not defined using namespaces.
$class = new stdClass(); $sxml = new SimpleXmlElement($xmlstr);
Automatic loading (namespace automatic loading) The namespaces under the Library directory can be automatically identified and located.
In addition to the namespace in the library directory, we can also define other namespaces
autoload_namespace
Improve the efficiency of class libraries mapping multiple root namespaces ThinkThink::addMap($map); $map=array();
Manually Third-party class library import import method imports any class library.
Built-in caching mechanism and running lite files Features of the new version Generate static entry files at runtime.
Application mode Application mode is to add automatic recognition area
Project compilation application compilation cache (cache for first run) - run Lite file (entry static)
-------------===== ======
Route definition
URL is not in normal mode. To enable routing, you can enable routing in the application (or module) configuration file
// Enable routing 'URL_ROUTER_ON' => true, 3.2 routing is for modules, so the module name It cannot be routed. The definition of routing is usually in the module configuration file.
Route expression => Routing address and incoming parameters Array('Routing expression', 'Routing address', 'Incoming parameters')
Routing expression
Regular expression/^blog/(d+)$/
Regular expression blog/:id
Exact match $
Public method
-------
Controller
If the method to be operated is a controller method that conflicts with the system's keywords, we can set The suffix method
solve'ACTION_SUFFIX'=> 'Action', // The operation method suffix
multi-level controller is to group the controllers
If the instantiated controller is internal, it will be automatically instantiated when using url address resolution If it is called across controllers, instantiate it and call it using shortcut method A (if it is multi-level, use the second parameter of A). You can instantiate the method when instantiating it. Pre- and post-operations (only useful for controllers)
The common ones are _before_index pre-method_after_index post-method If no pre-post method is defined, the real template output may only be the current operation. Pre- and post-operations generally have no output. If the call error operation is successful, there will be no post-operation.
The controller can also bind parameter rules and action parameter binding (variable names can be bound to implement routing functions)
Pseudo-static
URL_HTML_SUFFIX=〉'' The static suffix is recorded to the constant __EXT__ (the current suffix can be obtained)
URL_DENY_SUFFIX= 〉Multiple suffixes that are not allowed to be accessed are separated by |
The priority below is higher than the one above
URL case 'URL_CASE_INSENSITIVE' =>true When accessing the controller is not case sensitive, capitalize it with _
The system provides the U method to automatically generate the relevant URL address for you
U Similar (redirect) (URL generation)
In order to match the URL mode used, we need to be able to dynamically generate the corresponding URL address based on the current URL settings. To this end,
ThinkPHP provides a built-in U method for dynamic generation of URLs , which can ensure that the project is not affected by the environment during the migration process.
U('Address expression',['Parameter'],['Pseudo-static suffix'],['Display domain name'])
[Module/Controller/Operation#anchor@domain name]?Parameter 1=Value 1& Parameter 2=value 2...
ajax returns ajaxReturn
The data returned by the variable array can be processed by JSON, JSONP, XML and EVAL. The method can be configured to return DEFAULT_AJAX_RETURN. eval can output $data data
JSON and JSONP Although there is only one letter difference, they are actually not the same thing at all: JSON is a data exchange format, while JSONP is an unofficial cross-domain data exchange protocol. One is the format of describing the information, and the other is the agreed method of transmitting the information.
Jump and redirect
$this->success(prompt information, address, seconds)
----==--=-=
Input variables
You can obtain and filter variables through the I function
I( 'Variable type. Variable name', ['Default value'], ['Filter method'], ['Additional data source'])
The I function comes with DEFAULT_FILTER and the default is htmlspecialchars (Filtering of variables)
Judgment request Type (request type)
is_XXX If it is custom AJAX, you need to add a hidden field to tell the background that it was submitted by ajax. If it is jquery
it is not needed. It can be configured through VAR_AJAX_SUBMI
Empty operation
Automatically call _empty (implementing error pages and some url optimization)
The empty controller system tries to determine the EmptyController
The operation is bound to the class ACTION_BIND_CLASS=〉'true' is more detailed and cannot be omitted
Before The postfix operation needs to be defined in advance
-=-=-=-=-=-=-=-=-=-=-=-
Model Case and conversion
Direct instantiation of the model class generally inherits the model class model Generally there are 3 values: model name data table prefix number
Database connection information
If you want to write native sql code, you only need to instantiate empty M();
D (instantiation operation of data model)
Parameters of the method It is the name of the model, and is consistent with the uppercase and lowercase definition of the model class.
When the class does not exist, the D function will try to instantiate the public module, and can also be used across modules
M (just perform basic operations on the data table CURD operation) does not require loading specific model classes, so the performance is higher.
Does not support its own business logic
During the instantiation process, we often use the D method and the M method. The difference between these two methods is the M method. Instantiating the model does not require the user to define a model class for each data table. If the D method does not find the defined model class, the M
method will be automatically used.
The field cache includes the field information in the field. You can turn off the automatic caching of fields by setting DB_FIELDS_CACHE. Add this field in the project configuration
file
Get all the field information of the data table getDbFields(); field(''/*); Get the call All fields field
(true).
Use table() to switch data tables; When connecting to the database, you can add a label to the connection
System default rules, you must use the model execute write operation query read operation
continuous operation (chain operation)
where can be used in conjunction with where
The data method is for writing to the database and can also be used for updating (save) to determine whether there is a primary key. The object can be a number
group, object or string. Read operations are possible.
field gets the field, and the fields excluded are filed(array('user_id','content'),true); which are fields other than user_id and
content. Used for writing (security control) and does not allow other writing $model->field('name')-
>create(); means that the only legal fields in the form are the name field, no matter what the user passes Means changed or added browser
The submission fields will be directly blocked. Since all other fields we do not want to be determined by user submission, you can define additional fields to write through the
autocomplete function.
filert (filtering of field content) is somewhat similar to I’s judgment $User->data($data)->filter ('strip_tags')->add(); Filter out HTML tags (supports callback type functions It can be a function or a closure
Definition)
The having method is to cooperate with the group method to query again from the grouped results.
Cache Sm Comment Note
The data object created by the Create method is that it is stored in the memory, and it is not actually written into the database until the ADD
or Save method is really written into the database. It is written to the database after add or save, so the create object can be changed before there is any change.
----
find (read a field) select (read the field set) getField (read the field value )[Number update setInc setDec]
delete() [It will not be deleted when no conditions are passed in, similar to seve]
When the form mapping data is obtained, the automatic processing setting is turned on 'READ_DATA_MAP'=>true
You can also use parseFieldsMap to convert the format
Query method
Array'_logic'='OR' Use object mode to query stdClass
$map['b'] =array('notlike',array('%thinkphp%', '%tp'),'AND');
exp expression query (exp query conditions will not be treated as strings) All subsequent query conditions can use any syntax supported by
sql, including the use of functions and field names. Query expressions can be used not only for query conditions, but also for numbers.
As updated.
$data['score'] = array('exp','score+1');// Add 1 to the user's points
$User->where('id=5')->save($data ); // Save modified data according to conditions
Support for multi-language packages L
*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_* _12_1
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Instancing controller
distinct
(token verification) token
ORM Table mapping to class record mapping to object
AR mode ActiveRecord A simple command
How to enable local session management with prefix Support
*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_* _12_1

“你的组织要求你更改PIN消息”将显示在登录屏幕上。当在使用基于组织的帐户设置的电脑上达到PIN过期限制时,就会发生这种情况,在该电脑上,他们可以控制个人设备。但是,如果您使用个人帐户设置了Windows,则理想情况下不应显示错误消息。虽然情况并非总是如此。大多数遇到错误的用户使用个人帐户报告。为什么我的组织要求我在Windows11上更改我的PIN?可能是您的帐户与组织相关联,您的主要方法应该是验证这一点。联系域管理员会有所帮助!此外,配置错误的本地策略设置或不正确的注册表项也可能导致错误。即

Windows11将清新优雅的设计带到了最前沿;现代界面允许您个性化和更改最精细的细节,例如窗口边框。在本指南中,我们将讨论分步说明,以帮助您在Windows操作系统中创建反映您的风格的环境。如何更改窗口边框设置?按+打开“设置”应用。WindowsI转到个性化,然后单击颜色设置。颜色更改窗口边框设置窗口11“宽度=”643“高度=”500“>找到在标题栏和窗口边框上显示强调色选项,然后切换它旁边的开关。若要在“开始”菜单和任务栏上显示主题色,请打开“在开始”菜单和任务栏上显示主题

默认情况下,Windows11上的标题栏颜色取决于您选择的深色/浅色主题。但是,您可以将其更改为所需的任何颜色。在本指南中,我们将讨论三种方法的分步说明,以更改它并个性化您的桌面体验,使其具有视觉吸引力。是否可以更改活动和非活动窗口的标题栏颜色?是的,您可以使用“设置”应用更改活动窗口的标题栏颜色,也可以使用注册表编辑器更改非活动窗口的标题栏颜色。若要了解这些步骤,请转到下一部分。如何在Windows11中更改标题栏的颜色?1.使用“设置”应用按+打开设置窗口。WindowsI前往“个性化”,然

您是否在Windows安装程序页面上看到“出现问题”以及“OOBELANGUAGE”语句?Windows的安装有时会因此类错误而停止。OOBE表示开箱即用的体验。正如错误提示所表示的那样,这是与OOBE语言选择相关的问题。没有什么可担心的,你可以通过OOBE屏幕本身的漂亮注册表编辑来解决这个问题。快速修复–1.单击OOBE应用底部的“重试”按钮。这将继续进行该过程,而不会再打嗝。2.使用电源按钮强制关闭系统。系统重新启动后,OOBE应继续。3.断开系统与互联网的连接。在脱机模式下完成OOBE的所

任务栏缩略图可能很有趣,但它们也可能分散注意力或烦人。考虑到您将鼠标悬停在该区域的频率,您可能无意中关闭了重要窗口几次。另一个缺点是它使用更多的系统资源,因此,如果您一直在寻找一种提高资源效率的方法,我们将向您展示如何禁用它。不过,如果您的硬件规格可以处理它并且您喜欢预览版,则可以启用它。如何在Windows11中启用任务栏缩略图预览?1.使用“设置”应用点击键并单击设置。Windows单击系统,然后选择关于。点击高级系统设置。导航到“高级”选项卡,然后选择“性能”下的“设置”。在“视觉效果”选

在Windows11上的显示缩放方面,我们都有不同的偏好。有些人喜欢大图标,有些人喜欢小图标。但是,我们都同意拥有正确的缩放比例很重要。字体缩放不良或图像过度缩放可能是工作时真正的生产力杀手,因此您需要知道如何对其进行自定义以充分利用系统功能。自定义缩放的优点:对于难以阅读屏幕上的文本的人来说,这是一个有用的功能。它可以帮助您一次在屏幕上查看更多内容。您可以创建仅适用于某些监视器和应用程序的自定义扩展配置文件。可以帮助提高低端硬件的性能。它使您可以更好地控制屏幕上的内容。如何在Windows11

屏幕亮度是使用现代计算设备不可或缺的一部分,尤其是当您长时间注视屏幕时。它可以帮助您减轻眼睛疲劳,提高易读性,并轻松有效地查看内容。但是,根据您的设置,有时很难管理亮度,尤其是在具有新UI更改的Windows11上。如果您在调整亮度时遇到问题,以下是在Windows11上管理亮度的所有方法。如何在Windows11上更改亮度[10种方式解释]单显示器用户可以使用以下方法在Windows11上调整亮度。这包括使用单个显示器的台式机系统以及笔记本电脑。让我们开始吧。方法1:使用操作中心操作中心是访问

在iOS17中,Apple为其移动操作系统引入了几项新的隐私和安全功能,其中之一是能够要求对Safari中的隐私浏览选项卡进行二次身份验证。以下是它的工作原理以及如何将其关闭。在运行iOS17或iPadOS17的iPhone或iPad上,如果您在Safari浏览器中打开了任何“无痕浏览”标签页,然后退出会话或App,Apple的浏览器现在需要面容ID/触控ID认证或密码才能再次访问它们。换句话说,如果有人在解锁您的iPhone或iPad时拿到了它,他们仍然无法在不知道您的密码的情况下查看您的隐私


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor
