Commit 7ec7259a authored by clone's avatar clone

1

parent f796db04
...@@ -102,20 +102,23 @@ class ABindingDevice extends BaseModel ...@@ -102,20 +102,23 @@ class ABindingDevice extends BaseModel
* @param string $field * @param string $field
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getDeviceNewByAgentId(array $params, string $field ) public function getDeviceNewByAgentId(array $params, string $field)
{ {
$where_ = []; $where_ = $str = "1=1";
if (isset($params["agent_id"])) { if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"]; $where_ .= " and agent_id =" . $params["agent_id"];
$str = $where_;
$where_ .= " and is_pc = 0 ";
$str .= " and is_pc = 1 ";
} }
try { try {
$data = $this $sql = "select $field from (
->field($field) (SELECT $field FROM $this->table where $where_ order by update_time desc limit 5)
->where($where_) union
->order("update_time desc") (SELECT $field FROM $this->table where $str order by update_time desc limit 5)
->limit(5) ) as aa order by aa.update_time desc";
->select(); $data = $this->query($sql);
} catch (\Exception $e) { } catch (\Exception $e) {
$data = []; $data = [];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment