Batmanage_model.php 764 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. if (!defined('BASEPATH'))exit('No direct script access allowed');
  3. class Batmanage_model extends CI_Model {
  4. public function __construct() {
  5. parent::__construct();
  6. }
  7. public function get_record_id($data, $table){
  8. $this->db->where('cmdtype', $data['cmdtype']);
  9. $this->db->where('relateid', $data['relateid']);
  10. $query = $this->db->get($table);
  11. $row = $query->row_array();
  12. if (!empty($row)) {
  13. // if ($table=='batch_update_cmd' && $row['statuscmd']==0 && (time() - strtotime($row['updatetime']) < 120)) {
  14. // return -1;
  15. // } else {
  16. $this->db->where('id', $row['id']);
  17. $this->db->update($table, $data);
  18. return $row['id'];
  19. // }
  20. } else {
  21. $this->db->insert($table, $data);
  22. return $this->db->insert_id();
  23. }
  24. }
  25. }
  26. ?>