- // model conf.php
- <?php
- class Conf extends Model {
- var $autore = '';
- var $titolo = '';
- var $anno = '';
- var $formato = '';
- var $Label = '';
- var $riddim = '';
- function hi()
- {
- $hi = '<h1>hi</h1>';
- return $hi;
- }
- function conf()
- {
- // Call the Model constructor
- parent::Model();
- }
- function tot()
- {
- $q = $this->db->get('tbl_name');
- return $q->result();
- }
- function one()
- {
- $one = $this->db->get('tbl_name', 1);
- return $one->result();
- }
- //kickass
- function get($offset = null, $limit = null)
- {
- $this->db->get('tbl_name');
- if (isset($offset) && isset($limit)) {
- $this->db->limit($offset, $limit);
- }
- return $this->db->result();
- }
- function insert_entry()
- {
- $this->autore = $this->input->post('autore');
- $this->titolo = $this->input->post('titolo');
- $this->anno = $this->input->post('anno');
- $this->formato = $this->input->post('formato');
- $this->Label = $this->input->post('Label');
- $this->riddim = $this->input->post('riddim');
- // $this->date = time();
- $this->db->insert('tbl_name', $this);
- }
- function update_entry()
- {
- $this->autore = $this->input->post('autore');
- $this->titolo = $this->input->post('titolo');
- $this->anno = $this->input->post('anno');
- $this->formato = $this->input->post('formato');
- $this->Label = $this->input->post('Label');
- $this->riddim = $this->input->post('riddim');
- $this->date = time();
- $this->db->update('tbl_name', $this, array('id' => $_POST['id']));
- }
- // end class
- }
- ?>
- controller page.php
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- class Page extends Controller {
- function Page(){
- parent::Controller();
- $this->load->model('conf');
- }
- function index()
- {
- $this->show();
- }
- function view($offset, $limit) {
- $this->conf->get($limit, $offset);
- }
- function pag($offset = 0)
- {
- $limit = 1;
- $tot_rows = $this->db->count_all('canzoni');
- $this->load->library('pagination');
- $this->load->helper('url');
- $this->load->helper('html');
- $config['lista'] = $this->db->get('canzoni',$limit,$offset);
- $config['base_url'] = site_url('pag/');
- $config['total_rows'] = $tot_rows;
- $config['per_page'] = $limit;
- $offset = $this->uri->segment(3);
- $this->pagination->initialize($config);
- $this->pagination->create_links();
- }
- function show($page = 'index')
- {
- $data = array();
- $data['hi'] = $this->conf->hi();
- $data['tot'] = $this->conf->tot();
- $data['one'] = $this->conf->one();
- if( ! file_exists(APPPATH.'views/pages/'.$page.EXT))
- {
- show_404();
- }
- // $this->load->helper('paginator');
- // echo pagina();
- // $this->load->library('ion_auth');
- // $this->pagina();
- //$data['lista'] = $this->db->get('canzoni',$limit,$offset);
- $this->load->view("/pages/" . $page, $data);
- }
- }
- ?>
- view homw.php
- <?php extend('master_template.php') ?>
- <?php startblock('content') ?>
- <dl>
- <?php foreach($tot as $row) { ?>
- <dt><?php echo $row->autore; ?></dt>
- <dd><?php echo $row->titolo; ?>
- <ul>
- <li>
- <?php echo $row->anno; ?>
- </li>
- <li>
- <?php echo $row->Label; ?>
- </li>
- <li>
- <?php echo $row->formato; ?>
- </li>
- </ul>
- </dd>
- <?php }; ?>
- </dl>
- <?php
- print $hi;?>
- <?php endblock() ?>
- <?php end_extend() ?>