Network_model.php 934 B

1234567891011121314151617181920212223242526272829
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. include_once(FCPATH . 'application/models/Base_model.php');
  3. class Network_model extends Base_Model {
  4. protected $table = 'network';
  5. // 添加路灯数(复用)
  6. public function add_lamp_count($id,$count){
  7. $sql = "update `{$this->table}` set `lampcount` = `lampcount` + {$count} WHERE `id`={$id}";
  8. $this->db->query($sql);
  9. if ($this->db->affected_rows() == 1) {
  10. return true;
  11. } else {
  12. return false;
  13. }
  14. }
  15. // 减少路灯数(复用)
  16. public function minus_lamp_count($id,$count){
  17. $sql = "update `{$this->table}` set `lampcount` = `lampcount` - {$count} WHERE `id`={$id} and `lampcount` >= {$count}";
  18. $this->db->query($sql);
  19. if ($this->db->affected_rows() == 1) {
  20. return true;
  21. } else {
  22. return false;
  23. }
  24. }
  25. }