getPath.php 1020 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. include("connectSQL_Component.php");
  3. $array = [];
  4. $table = [];
  5. if(isset($_GET["type"])){
  6. $type = urldecode($_GET["type"]);
  7. $sql = "SELECT * FROM [BIMComponents].[dbo].[API_Table] Where [type] = '".$type."';";
  8. }
  9. else
  10. $sql = "SELECT * FROM [BIMComponents].[dbo].[API_Table]";
  11. $fetchResult = sqlsrv_query($conn, $sql);
  12. while ($row = sqlsrv_fetch_array($fetchResult)) {
  13. array_push($table, $row);
  14. }
  15. $array["table"] = $table;
  16. $table = [];
  17. $sql = "SELECT DISTINCT object FROM [BIMComponents].[dbo].[API_Table]";
  18. $fetchResult = sqlsrv_query($conn, $sql);
  19. while ($row = sqlsrv_fetch_array($fetchResult)) {
  20. if ($row["object"] != null)
  21. array_push($table, $row);
  22. }
  23. $array["objectFilter"] = $table;
  24. $table = [];
  25. $sql = "SELECT DISTINCT usage FROM [BIMComponents].[dbo].[API_Table]";
  26. $fetchResult = sqlsrv_query($conn, $sql);
  27. while ($row = sqlsrv_fetch_array($fetchResult)) {
  28. if ($row["usage"] != null)
  29. array_push($table, $row);
  30. }
  31. $array["usageFilter"] = $table;
  32. echo json_encode($array);