Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Codeigniter 介绍

hjue
October 19, 2012

Codeigniter 介绍

hjue

October 19, 2012
Tweet

More Decks by hjue

Other Decks in Programming

Transcript

  1. Why CI • small • Fast • Simple • support

    command line • documentation • inherit Thursday, December 15, 11
  2. Controller example.com/index.php/first <?php class First extends CI_Controller{ function __construct() {

    parent::__construct(); } function index() { echo “<h1> Hello World !! </h1> “; } function demo(){ } } ?> application/controllers Thursday, December 15, 11
  3. Views Calling a VIEW from Controller $this->load->view(‘myview’); Data Passing to

    a VIEW from Controller function index() { $var = array( ‘full_name’ => ‘Amzad Hossain’, ‘email’ => ‘[email protected]’ ); $this->load->view(‘myview’, $var); } <html> <title> ..::Personal Info::.. </title> <body> Full Name : <?php echo $full_name;?> <br /> E-mail : <?=$email;?> <br /> </body> </html> application/controllers Thursday, December 15, 11
  4. Model Designed to work with Information of Database Models Should

    be placed Under “application/models/” <?php class Mymodel extend CI_Model{ function __construct() { parent::__construct(); } function get_info() { $query = $this->db->get(‘name’, 10); return $query->result(); } } ?> Loading a Model inside a Controller $this->load->model(‘mymodel’); $data = $this->mymodel->get_info(); Thursday, December 15, 11