What are the classical operation classes commonly used in CI framework
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')