Commit 7ec7259a authored by clone's avatar clone

1

parent f796db04
......@@ -102,20 +102,23 @@ class ABindingDevice extends BaseModel
* @param string $field
* @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"])) {
$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 {
$data = $this
->field($field)
->where($where_)
->order("update_time desc")
->limit(5)
->select();
$sql = "select $field from (
(SELECT $field FROM $this->table where $where_ order by update_time desc limit 5)
union
(SELECT $field FROM $this->table where $str order by update_time desc limit 5)
) as aa order by aa.update_time desc";
$data = $this->query($sql);
} catch (\Exception $e) {
$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