Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the classical operation classes commonly used in CI framework

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces what the CI framework commonly used classic operation classes are, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. URI in Super object

Information about parsing url of CI_URI class

You can use its related properties directly by using $this- > uri

In the system/core/URI.php file

Some common attributes:

(1) obtain url related information by segment

$this- > uri- > segment (4); / / get the value of the fourth segment of pathinfo// in url

Entry file .php / controller / action / parameter 1 / parameter 2.

(2) transfer parameters through the formal parameters in the method.

Need to set default values and order to pay attention to

Index.php/user/index/3/zhangsan

Public function index ($id=0,$name='') {echo $id,$name;}

Extension of 2.CI Controller

Under the application/core/ folder

Add your own extension controller

Class MY_Controller extends CI_Controller {public function _ _ construct () {parent::__construct}}

Configure model prefix

$config ['subclass_prefix'] =' MY_';// default

3. Related operations of the model

The file name is lowercase, and the class name is capitalized.

It is recommended that the class name be suffixed with _ model

Load the model in the controller:

Add the following to construct:

$this- > load- > model ('User_model'); $this- > User_model- > get ()

Alias the model

$this- > load- > model ('User_model','user'); $this- > user- > get ()

Common functions in 4.url

(1) help us generate controllers

$this- > load- > helper ('url'); site_url (' controller / method')

(2) the use of picture path

$this- > load- > helper ('url')

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report