Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 3.57 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // model conf.php
  2.  
  3. <?php
  4. class Conf extends Model {
  5.        
  6.         var $autore   = '';
  7.         var $titolo   = '';
  8.         var $anno     = '';
  9.         var $formato  = '';
  10.         var $Label    = '';
  11.         var $riddim   = '';
  12.        
  13.  
  14.     function hi()
  15.     {
  16.                 $hi = '<h1>hi</h1>';
  17.                 return $hi;
  18.         }
  19.        
  20.     function conf()
  21.     {
  22.         // Call the Model constructor
  23.         parent::Model();
  24.     }
  25.  
  26.     function tot()
  27.     {
  28.         $q = $this->db->get('tbl_name');
  29.         return $q->result();
  30.     }
  31.  
  32.     function one()
  33.     {
  34.         $one = $this->db->get('tbl_name', 1);
  35.         return $one->result();
  36.     }
  37.  
  38. //kickass
  39.         function get($offset = null, $limit = null)
  40.         {
  41.                 $this->db->get('tbl_name');
  42.                         if (isset($offset) && isset($limit)) {
  43.                                         $this->db->limit($offset, $limit);
  44.                         }
  45.                        
  46.                         return $this->db->result();
  47.         }
  48.  
  49.     function insert_entry()
  50.     {
  51.         $this->autore   = $this->input->post('autore');
  52.         $this->titolo = $this->input->post('titolo');
  53.         $this->anno = $this->input->post('anno');
  54.         $this->formato = $this->input->post('formato');
  55.         $this->Label = $this->input->post('Label');
  56.         $this->riddim = $this->input->post('riddim');
  57. //        $this->date    = time();
  58.  
  59.         $this->db->insert('tbl_name', $this);
  60.     }
  61.  
  62.     function update_entry()
  63.     {
  64.         $this->autore   = $this->input->post('autore');
  65.         $this->titolo = $this->input->post('titolo');
  66.         $this->anno = $this->input->post('anno');
  67.         $this->formato = $this->input->post('formato');
  68.         $this->Label = $this->input->post('Label');
  69.         $this->riddim = $this->input->post('riddim');
  70.         $this->date    = time();
  71.  
  72.         $this->db->update('tbl_name', $this, array('id' => $_POST['id']));
  73.     }
  74.  
  75. // end class
  76. }
  77. ?>
  78.  
  79. controller page.php
  80.  
  81. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  82.  
  83. class Page extends Controller {
  84.  
  85.         function Page(){
  86.                 parent::Controller();
  87.                 $this->load->model('conf');
  88.         }
  89.  
  90.         function index()
  91.         {
  92.                 $this->show();
  93.         }
  94.  
  95.         function view($offset, $limit) {
  96.                 $this->conf->get($limit, $offset);
  97.         }
  98.  
  99.         function pag($offset = 0)
  100.         {
  101.                 $limit = 1;
  102.  
  103.                 $tot_rows = $this->db->count_all('canzoni');
  104.  
  105.                 $this->load->library('pagination');
  106.                 $this->load->helper('url');
  107.                 $this->load->helper('html');
  108.  
  109.                 $config['lista'] = $this->db->get('canzoni',$limit,$offset);
  110.                 $config['base_url'] = site_url('pag/');
  111.                 $config['total_rows'] = $tot_rows;
  112.                 $config['per_page'] = $limit;
  113.  
  114.                 $offset = $this->uri->segment(3);              
  115.                
  116.                 $this->pagination->initialize($config);
  117.                 $this->pagination->create_links();
  118.         }
  119.  
  120.     function show($page = 'index')
  121.     {
  122.                 $data = array();
  123.  
  124.                 $data['hi'] = $this->conf->hi();
  125.         $data['tot'] =  $this->conf->tot();
  126.                 $data['one'] = $this->conf->one();
  127.  
  128.         if( ! file_exists(APPPATH.'views/pages/'.$page.EXT))
  129.         {
  130.             show_404();
  131.         }
  132.                
  133.         //      $this->load->helper('paginator');
  134.  
  135.         //      echo pagina();
  136. //              $this->load->library('ion_auth');
  137. // $this->pagina();
  138.                 //$data['lista'] = $this->db->get('canzoni',$limit,$offset);
  139.  
  140.         $this->load->view("/pages/" . $page, $data);
  141.     }
  142.  
  143. }
  144.  
  145. ?>
  146.  
  147. view homw.php
  148.  
  149. <?php extend('master_template.php') ?>
  150.  
  151.         <?php startblock('content') ?>
  152.  
  153.        
  154. <dl>
  155. <?php foreach($tot as $row) { ?>
  156.  
  157. <dt><?php echo $row->autore; ?></dt>
  158.         <dd><?php echo $row->titolo; ?>
  159.         <ul>
  160.         <li>
  161. <?php echo $row->anno; ?>
  162.         </li>
  163.         <li>
  164. <?php echo $row->Label; ?>
  165.         </li>
  166.         <li>
  167. <?php echo $row->formato; ?>
  168.         </li>
  169.         </ul>
  170.         </dd>
  171. <?php }; ?>
  172. </dl>
  173. <?php
  174. print $hi;?>
  175.  
  176.  
  177.         <?php endblock() ?>
  178.  
  179. <?php end_extend() ?>