Browse Source

no message

wzh 5 years ago
parent
commit
e9b5883e05
1 changed files with 31 additions and 0 deletions
  1. 31 0
      api/application/models/Batmanage_model.php

+ 31 - 0
api/application/models/Batmanage_model.php

@@ -0,0 +1,31 @@
+<?php
+if (!defined('BASEPATH'))exit('No direct script access allowed');
+
+class Batmanage_model extends CI_Model {
+
+	public function __construct() {
+		parent::__construct();
+	}
+	
+	public function get_record_id($data, $table){
+		$this->db->where('cmdtype', $data['cmdtype']);
+		$this->db->where('relateid', $data['relateid']);
+		$query = $this->db->get($table);
+		$row = $query->row_array();
+		if (!empty($row)) {
+			// if ($table=='batch_update_cmd' && $row['statuscmd']==0 && (time() - strtotime($row['updatetime']) < 120)) {
+			// 	return -1;
+			// } else {
+				$this->db->where('id', $row['id']);
+				$this->db->update($table, $data);
+				return $row['id'];
+			// }
+		} else {
+			$this->db->insert($table, $data);
+			return $this->db->insert_id();
+		}
+	}
+
+}
+
+?>