当前位置:网站首页>Ci framework learning of PHP
Ci framework learning of PHP
2022-07-27 07:09:00 【Tie Zhu】
One 、 Preface
I didn't expect that the new company would use CI frame , Although I've always heard , But we still use laravel,yii,tp A little more , First contact CI, It's worth noting .
About online CI There are many documents , Also very comprehensive , Bloggers here simply record . Those that need to be recorded in the future will continue to be supplemented ,, It's not a very friendly article for beginners ..
Two 、CI introduction
Manual address :http://codeigniter.org.cn/user_guide/
1、 see ci Version number of the frame
Global search in the project :CI_VERSION
define('CI_VERSION', '2.x');
2、 CI The frame sets the default controller
1. Get into application Of config Under the folder , find routes.php
2. See settings :$route['default_controller'] = "test"; // It means default access test Controller index Method
3、 How to call the core class library (system/core/config.php)
(1) Call the core library in the controller
$aa = $this->config->base_url();
(2) Call the logic file in the controller
$this->load->biz('test/test1'); // test1.php Is the logical file name
4、 Call of system class library (system/libraries/config.php)
$this->load->library('class_name'); // Call a single file
$this->load->library(array('email', 'table')); // Call multiple files
$this->class_name->error_array(); // At the end of the call , You can directly use the methods in the system class library
5、 Call of auxiliary function class (system/helps/test.php)
$this->load->library('test');
$casUserInfo = $this->test->xxx(); // After calling, you can directly use
6、 Call of model class (system/models/model_name.php)
$this->load->model('blog/model_name'); The reference is located in the model under the subdirectory
$this->model_name->method(); After loading , You can access the methods in the model through an object with the same name as your class .
7、 Render the page
$this->load->view($template, $data, TRUE);
8、 Other calls (redis)
// Need to be in config Folder new redis.php file , The configuration is written inside
$this->load->redis('key Name '); //redis
9、 Get and set config Value
echo $this->config->item('charset'); // obtain config Configured in charset value
$this->config->set_item('charset', 'gbk') // To reset config in charset Value
10、 The above methods are all in controller In the call , If not controller What to do in ?
To access from your custom class library CodeIgniter The original resources of , You have to use get_instance() function . This function returns one CodeIgniter super object.
$CI = &get_instance();
$CI->load->config('test1'); // load core Profile under , for example test1.php
$CI->load->model('xxx/test_db'); // load model The files under the
$CI->load->library('http'); // load library The files under the
$CI->load->redis('test'); // call redis
$CI->load->rabbitmq('test'); // call rabbitmq
$CI->load->view($template, $data, TRUE); // Render the page
11、ci Command line call
Call mode :php index.php controller Method Parameters
Example :
*/1 * * * * php Project directory /index.php test test_1 0 > /dev/null 2>&1
explain :
(1) Command line mode similar to other frameworks , The front is php Location , Followed by the project root directory index,php
(2) The following ones are separated by spaces , Controller file name (application Inside ), Method name , Parameters
(3) Method example :
// This is the corresponding method ,$index Is the parameter
public function test_1($index = 0)
{}
12、 Excellent introductory blog recommendation
https://www.cnblogs.com/lovele-/p/9434328.html
https://blog.csdn.net/qq_21806621/article/details/70992328
https://www.cnblogs.com/xiaoxiaoqingyi/p/6654190.html
end
边栏推荐
- Visual horizontal topic bug1:filenotfounderror: could not find module 'mvcameracontrol dll‘ (or one of it
- 硫化镉CdS量子点修饰脱氧核糖核酸DNA|CdS-DNA QDs|近红外CdS量子点偶联DNA规格信息
- 基于SSM音乐网站管理系统
- regular expression
- Fix the problem that the paging data is not displayed when searching the easycvr device management list page
- How to make the minimum API bind the array in the query string
- Speech and language processing (3rd ed. draft) Chapter 2 - regular expression, text normalization, editing distance reading notes
- Cyclegan parsing
- DNA偶联PbSe量子点|近红外硒化铅PbSe量子点修饰脱氧核糖核酸DNA|PbSe-DNA QDs
- 基于SSM学生成绩管理系统
猜你喜欢

Pytorch uses data_ Prefetcher improves data reading speed

Qi Yue: thiol modified oligodna | DNA modified cdte/cds core-shell quantum dots | DNA coupled indium arsenide InAs quantum dots InAs DNA QDs

Li Hongyi 2020 deep learning and human language processing dlhlp core resolution-p21

Consideration on how the covariance of Kalman filter affects the tracking effect of deepsort

基于SSM学生学籍管理系统

DNA modified noble metal nanoparticles | DNA modified gold nanoparticles (scientific research level)

vscode运行命令报错:标记“&&”不是此版本中的有效语句分隔符。

Campus news release management system based on SSM

Cass11.0.0.4 for autocad2010-2023 dog free usage

齐岳:巯基修饰寡聚DNA|DNA修饰CdTe/CdS核壳量子点|DNA偶联砷化铟InAs量子点InAs-DNA QDs
随机推荐
PNA peptide nucleic acid modified peptide suc Tyr Leu Val PNA | suc ala Pro Phe PNA 11
New features of ES6 (2)
Reflection on pytorch back propagation
Datascience: data generation adds a small amount of noise (customizable noise) to the original data to realize the construction of new data (dataframe format data storage case)
Digital image processing - Chapter 6 color image processing
Student status management system based on SSM
The issuing process of individual developers applying for code signing certificates
齐岳:巯基修饰寡聚DNA|DNA修饰CdTe/CdS核壳量子点|DNA偶联砷化铟InAs量子点InAs-DNA QDs
DNA (deoxyribonucleic acid) supply | carbon nanotube nucleic acid loaded dna/rna material | dna/rna nucleic acid modified magnetic nanoparticles
ZnS-DNA QDs近红外硫化锌ZnS量子点改性脱氧核糖核酸DNA|DNA修饰ZnS量子点
手机上也能训练BERT和ResNet了?!
CASS11.0.0.4 for AutoCAD2010-2023免狗使用方法
DNA科研实验应用|环糊精修饰核酸CD-RNA/DNA|环糊精核酸探针/量子点核酸探针
Matlab drawing (ultra detailed)
Watermelon book chapter 3 - linear model learning notes
Future, futuretask and completable future are often asked in interviews
Customer cases | focus on process experience to help bank enterprise app iteration
ESP8266(ESP-12F) 第三方库使用 -- SparkFun_APDS9960 (手势识别)
Unittest suite and runner
What is the reason why dragging the timeline is invalid when playing device videos on the easycvr platform?