cloud_model.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class Cloud_model extends MY_Model
  3. {
  4. private $table_name = 'cloud';
  5. private $orderby = 'ord';
  6. public function insert($parm)
  7. {
  8. $this->db->insert($this->table_name, $parm);
  9. return $this->db->insert_id();
  10. }
  11. public function delete($id) {
  12. $this->db->where('id', $id);
  13. $this->db->delete($this->table_name);
  14. return $this->db->affected_rows();
  15. }
  16. public function update($id, $parm) {
  17. $this->db->where('id', $id);
  18. $this->db->update($this->table_name, $parm);
  19. return $this->db->affected_rows();
  20. }
  21. public function get($id)
  22. {
  23. $this->db->select('*');
  24. $this->db->from($this->table_name);
  25. $this->db->where('id', $id);
  26. $query = $this->db->get();
  27. return $query->num_rows() > 0 ? $query->row_array() : false;
  28. }
  29. public function all()
  30. {
  31. $this->db->order_by($this->orderby, 'asc');
  32. $query = $this->db->get($this->table_name);
  33. return $query->num_rows() > 0 ? $query->result_array() : false;
  34. }
  35. public function max_ord()
  36. {
  37. $this->db->select('max(ord) as max_ord');
  38. $query = $this->db->get($this->table_name);
  39. $ret = $query->row_array();
  40. return $ret['max_ord'];
  41. }
  42. }