Advertisement
kotvalera83

codeigniter model ar

Oct 14th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Simply_model extends CI_Model {
  4.  
  5. function get($table)
  6.     {
  7.         $this->db->select();
  8.         $query = $this->db->get($table);
  9.         return $query->result_array();
  10.     }
  11.  
  12. function get_where($table, $id, $idtab)
  13.     {
  14.         $this->db->select();
  15.         $this->db->where($idtab, $id);
  16.         $query = $this->db->get($table);
  17.         return $query->result_array();
  18.     }
  19.  
  20. function get_where_first_row($table, $id, $idtab)
  21.     {
  22.         $this->db->select();
  23.         $this->db->where($idtab, $id);
  24.         $query = $this->db->get($table);
  25.         return $query->first_row();
  26.     }
  27.  
  28. function save($insert_data, $table)
  29.     {
  30.        $insert = $this->db->insert($table, $insert_data);
  31.        return $insert;
  32.     }
  33.  
  34. function delete($table, $id, $idtab)
  35.     {
  36.         $query = $this->db->delete($table, array($idtab => $id));
  37.         return $query;
  38.     }
  39.  
  40. function update($data, $table, $id, $idtab)
  41.     {
  42.         $this->db->where($idtab, $id);
  43.         $update = $this->db->update($table, $data);
  44.         return $update;
  45.     }
  46.  
  47. }
  48.  
  49. /* End of file simply_model.php */
  50. /* Location: ./application/models/simply_model.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement