当前位置:网站首页>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
边栏推荐
- Digital image processing -- Chapter 3 gray scale transformation and spatial filtering
- Interpretation of deepsort source code (I)
- [unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature
- TS learning (VIII): classes in TS
- VScode连接远程服务器开发
- ZnS-DNA QDs近红外硫化锌ZnS量子点改性脱氧核糖核酸DNA|DNA修饰ZnS量子点
- Qi Yue: thiol modified oligodna | DNA modified cdte/cds core-shell quantum dots | DNA coupled indium arsenide InAs quantum dots InAs DNA QDs
- Pytorch model
- DNA科研实验应用|环糊精修饰核酸CD-RNA/DNA|环糊精核酸探针/量子点核酸探针
- Common problems in converting pytorch to onnx
猜你喜欢

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

Event capture and bubbling - what is the difference between them?

ESP8266(ESP-12F) 第三方库使用 -- SparkFun_APDS9960 (手势识别)

基于SSM实现的校园新闻发布管理系统

含有偶氮苯单体的肽核酸寡聚体(NH2-TNT4,N-PNAs)齐岳生物定制

基于SSM学生成绩管理系统
![Jest single test style problem [identity obj proxy] NPM package](/img/1d/7845a6da9c09bfdde7676a37579225.png)
Jest single test style problem [identity obj proxy] NPM package

Visual horizontal topic bug1:filenotfounderror: could not find module 'mvcameracontrol dll‘ (or one of it

DNA修饰贵金属纳米颗粒|脱氧核糖核酸DNA修饰纳米金(科研级)

Introduction to the official functions of easyrecovery14 data recovery software
随机推荐
ZnS-DNA QDs近红外硫化锌ZnS量子点改性脱氧核糖核酸DNA|DNA修饰ZnS量子点
Li Hongyi 2020 deep learning and human language processing dlhlp conditional generation by RNN and attention-p22
Mysql database
Day012 一维数组的应用
基于SSM学生成绩管理系统
含有偶氮苯单体的肽核酸寡聚体(NH2-TNT4,N-PNAs)齐岳生物定制
Basic statement of MySQL (1) - add, delete, modify and query
Gbase 8C - SQL reference 6 SQL syntax (11)
Jest single test style problem [identity obj proxy] NPM package
DNA modified near infrared two region GaAs quantum dots | GaAs DNA QDs | DNA modified GaAs quantum dots
Gbase 8C - SQL reference 6 SQL syntax (15)
MySQL的基本语句(1)—增删改查
Peptide nucleic acid oligomer containing azobenzene monomer (nh2-tnt4, n-pnas) Qiyue biological customization
MangoDB
DataScience:数据生成之在原始数据上添加小量噪声(可自定义噪声)进而实现构造新数据(dataframe格式数据存储案例)
【12】 Understand the circuit: from telegraph to gate circuit, how can we "send messages from thousands of miles"?
网易云信亮相 GIAC 全球互联网架构大会,解密新一代音视频架构在元宇宙场景的实践...
Student status management system based on SSM
Norms of vectors and matrices
Add virtual network card and configure OP route in win10