当前位置:网站首页>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
边栏推荐
- deepsort源码解读(七)
- Hospital reservation management system based on SSM
- DNA修饰贵金属纳米颗粒|脱氧核糖核酸DNA修饰纳米金(科研级)
- deepsort源码解读(三)
- Why can cross entropy loss be used to characterize loss
- DNA modified zinc oxide | DNA modified gold nanoparticles | DNA coupled modified carbon nanomaterials
- Peptide nucleic acid oligomer containing azobenzene monomer (nh2-tnt4, n-pnas) Qiyue biological customization
- Where to connect with user-defined functions leads to slow queries
- DNA coupled PbSe quantum dots | near infrared lead selenide PbSe quantum dots modified DNA | PbSe DNA QDs
- Error in running code: libboost_ filesystem.so.1.58.0: cannot open shared object file: No such file or directory
猜你喜欢

Analysis on the current situation and optimization strategy of customer experience management in banking industry

CdS quantum dots modified DNA | CDs DNA QDs | near infrared CdS quantum dots coupled DNA specification information

Book borrowing management system based on SSM

How to make the minimum API bind the array in the query string

Watermelon book learning Chapter 5 --- neural network

Dimension problems and contour lines

PNA肽核酸修饰多肽Suc-Tyr-Leu-Val-pNA|Suc-Ala-Pro-Phe-pNA 11

Student status management system based on SSM

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

Leetcode series (I): buying and selling stocks
随机推荐
强网杯2021 pwn 赛题解析——babypwn
DNA (deoxyribonucleic acid) supply | carbon nanotube nucleic acid loaded dna/rna material | dna/rna nucleic acid modified magnetic nanoparticles
Add virtual network card and configure OP route in win10
Account management and authority
Basic statement of MySQL (1) - add, delete, modify and query
Interpretation of deepsort source code (VII)
DNA修饰贵金属纳米颗粒|脱氧核糖核酸DNA修饰纳米金(科研级)
regular expression
Basic concepts of program, process, thread, coprocess, single thread and multi thread
New features of ES6 (2)
Livox SLAM(带LIO+闭环检测优化)
VIVO应用市场APP上架总结
Li Hongyi 2020 deep learning and human language processing dlhlp core resolution-p21
How to delete or replace the loading style of easyplayer streaming media player?
CASS11.0.0.4 for AutoCAD2010-2023免狗使用方法
How to learn C language? This article gives you the complete answer
Gbase 8C - SQL reference 6 SQL syntax (15)
Details of cross entropy loss function in pytorch
基于SSM实现的校园新闻发布管理系统
Variance and covariance