Advertisement
eqeqwan21

Untitled

Oct 14th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. private function get_circuit()
  2.  {
  3.     $arg = null;
  4.    
  5.     if(isset($_GET['id'])) {
  6.         $arg = array($_GET['id']);
  7.         $where = ' AND Devices.id=?';
  8.     }
  9.    
  10.     $sql="
  11.     select Devices.Name, Devices.CustomNum, lns.* from Devices
  12.     inner join (SELECT Devices_id, group_concat(
  13.     concat_ws( \",\", if(Switch=0,\"\",concat(\"S\",Switch)), concat(Phase,
  14.     case
  15.         when `Type`=1 then \"U\"
  16.         when `Type`=2 then \"I\"
  17.         when `Type`=3 then \"K\"
  18.         else \"P\"
  19.     end
  20.     ))) as qs from `Lines` group by 1) as lns on lns.Devices_id=Devices.id
  21.     where Devices.`Type`=1 $where
  22.     having qs LIKE '%S%'
  23.     order by CustomNum, `Name`
  24.     ";
  25.     $this->run_query($sql, $arg, ['Devices', 'Lines']);
  26.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement