-
-
Save arunoda/05595dd8d1b5c61cb3db to your computer and use it in GitHub Desktop.
Codeigniter - Models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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