Skip to content

Instantly share code, notes, and snippets.

@cikal
Created May 5, 2017 02:30
Show Gist options
  • Save cikal/059a28a69cc64747a8122244a6c62bf5 to your computer and use it in GitHub Desktop.
Save cikal/059a28a69cc64747a8122244a6c62bf5 to your computer and use it in GitHub Desktop.
for : Muhammad Abu Bakar As'sidiq (Group CI - Indo)
<?php
/* ------------------------------------------------------------------------
* File Controller
*/ ------------------------------------------------------------------------
defined('BASEPATH') OR exit('No direct script access allowed');
class Coba extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('m_coba');
}
public function index()
{
$data['query'] = $this->m_coba->get_all();
$this->load->view('v_coba', $data);
}
}
/* End of file Coba.php */
/* Location: ./application/controllers/Coba.php */
<?php
/* ------------------------------------------------------------------------
* File Model
*/ ------------------------------------------------------------------------
defined('BASEPATH') OR exit('No direct script access allowed');
class M_coba extends CI_Model {
function get_all() {
return $this->db->get('tb_nama');
}
}
/* End of file M_coba.php */
/* Location: ./application/models/M_coba.php */
/* ------------------------------------------------------------------------
* File SQL
*/ ------------------------------------------------------------------------
CREATE TABLE `tb_nama` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`nama` TEXT
);
<?php
/* ------------------------------------------------------------------------
* File View
*/ ------------------------------------------------------------------------
$rs = array();
foreach ($query->result() as $t) {
$rs[] = $t;
}
$json = json_encode($rs);
print $json;
/* End of file v_coba.php */
/* Location: ./application/views/v_coba.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment