Skip to content

Instantly share code, notes, and snippets.

@arunoda
Created June 14, 2012 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arunoda/05595dd8d1b5c61cb3db to your computer and use it in GitHub Desktop.
Save arunoda/05595dd8d1b5c61cb3db to your computer and use it in GitHub Desktop.
Codeigniter - Models
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Hello extends CI_Controller {
public function index() {
//
echo "This is my index function";
}
public function one($name) {
$this->load->model("hello_model", "model");
$profile = $this->model->getProfile("arunoda");
$this->load->view('header');
$data = array("n" => $name);
$data['profile'] = $profile;
$this->load->view('one', $data);
}
public function two() {
//
echo "This is the two";
}
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Hello_model extends CI_Model {
public function getProfile($name) {
return array("fullName" => "Arunoda Susiripala", "age" => 34);
}
}
<h1>This is the One</h1>
Hello, <?php echo $profile["fullName"]; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment