1234567891011121314151617181920212223242526272829 |
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- include_once(FCPATH . 'application/models/Base_model.php');
- class Network_model extends Base_Model {
- protected $table = 'network';
- // 添加路灯数(复用)
- public function add_lamp_count($id,$count){
- $sql = "update `{$this->table}` set `lampcount` = `lampcount` + {$count} WHERE `id`={$id}";
- $this->db->query($sql);
- if ($this->db->affected_rows() == 1) {
- return true;
- } else {
- return false;
- }
- }
- // 减少路灯数(复用)
- public function minus_lamp_count($id,$count){
- $sql = "update `{$this->table}` set `lampcount` = `lampcount` - {$count} WHERE `id`={$id} and `lampcount` >= {$count}";
- $this->db->query($sql);
- if ($this->db->affected_rows() == 1) {
- return true;
- } else {
- return false;
- }
- }
- }
|