CI框架调用系统类库链接提示方法快捷选择

我们的控制器类主要是继承CI_Controller,因此只要在CI_Controller类的头部添加属性对应相关类即可。或许说的不明,请直接看代码。文件:system/core/Controller.php
@property为添加的属性说明代码。
调用实例如:$this->input->get();在IDE中当输入到input->时就会提示get等相关方法。
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package                CodeIgniter
* @author                ExpressionEngine Dev Team
* @copyright        Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license                http://codeigniter.com/user_guide/license.html
* @link                http://codeigniter.com
* @since                Version 1.0
* @filesource
*/

// ------------------------------------------------------------------------

/**
* CodeIgniter Application Controller Class
*
* This class object is the super class that every library in
* CodeIgniter will be assigned to.

* @property CI_Loader            $load
* @property CI_DB_active_record  $db
* @property CI_Calendar          $calendar
* @property CI_Email             $email
* @property CI_Encrypt           $encrypt
* @property CI_Ftp               $ftp
* @property CI_Hooks             $hooks
* @property CI_Image_lib         $image_lib
* @property CI_Language          $language
* @property CI_Log               $log
* @property CI_Output            $output
* @property CI_Pagination        $pagination
* @property CI_Parser            $parser
* @property CI_Session           $session
* @property CI_Sha1              $sha1
* @property CI_Table             $table
* @property CI_Trackback         $trackback
* @property CI_Unit_test         $unit
* @property CI_Upload            $upload
* @property CI_URI               $uri
* @property CI_User_agent        $agent
* @property CI_Validation        $validation
* @property CI_Form_validation   $form_validation
* @property CI_Xmlrpc            $xmlrpc
* @property CI_Zip               $zip
* @property CI_Config            $config
* @property CI_Input             $input
* @property CI_Cache             $cache

* @package                CodeIgniter
* @subpackage        Libraries
* @category        Libraries
* @author                ExpressionEngine Dev Team
* @link                http://codeigniter.com/user_guide/general/controllers.html
*/
class CI_Controller {
..........省略...........

我们在调用自己model类方法也是一样的道理,如
1、我们写了一个test_model.php类(Test_model extends CI_Model)。
2、再写一个控制器test.php(Test extends CI_Controller)。
test.php代码:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**

* @property Test_model     $test_model
* @author LINK TEAM
*
*/
class Test extends CI_Controller {
        public function __construct()
        {
                parent::__construct();
                $this->load->model("test_model");
        }

        public function test()
        {
                $query = $this->test_model->getdata();//这里的方法在IDE中就会自动提示选择
        }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章