123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- class Cloud_model extends MY_Model
- {
-
- private $table_name = 'cloud';
- private $orderby = 'ord';
-
- public function insert($parm)
- {
- $this->db->insert($this->table_name, $parm);
- return $this->db->insert_id();
- }
- public function delete($id) {
- $this->db->where('id', $id);
- $this->db->delete($this->table_name);
- return $this->db->affected_rows();
- }
-
- public function update($id, $parm) {
- $this->db->where('id', $id);
- $this->db->update($this->table_name, $parm);
- return $this->db->affected_rows();
- }
- public function get($id)
- {
- $this->db->select('*');
- $this->db->from($this->table_name);
- $this->db->where('id', $id);
- $query = $this->db->get();
- return $query->num_rows() > 0 ? $query->row_array() : false;
- }
-
- public function all()
- {
- $this->db->order_by($this->orderby, 'asc');
- $query = $this->db->get($this->table_name);
- return $query->num_rows() > 0 ? $query->result_array() : false;
- }
- public function max_ord()
- {
- $this->db->select('max(ord) as max_ord');
- $query = $this->db->get($this->table_name);
- $ret = $query->row_array();
- return $ret['max_ord'];
- }
- }
|