oracle.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
  3. $db = "(DESCRIPTION =
  4. (ADDRESS_LIST =
  5. (ADDRESS = (PROTOCOL = TCP)(HOST = P-BDD-16)(PORT = 1521))
  6. )
  7. (CONNECT_DATA =
  8. (SERVICE_NAME = SIGCG50)
  9. )
  10. )";
  11. // Connexion au service
  12. $conn = oci_connect('ELIGIBILITE_R', 'H6nmb0KCwR', $db);
  13. if (!$conn) {
  14. $e = oci_error();
  15. echo 'Not connected';
  16. echo trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
  17. }
  18. $x = -1.109669152209201;
  19. $y = 49.102353729303125;
  20. $query1 = "Select A.Id_Zapm_Partielle From SIG_ANT.Ftth_Mn_Zapm_Partielle a WHERE SDO_CONTAINS(a.GEOMETRY, Mdsys.Sdo_Geometry(2001,4326,Mdsys.Sdo_Point_Type(".$x.", ".$y.", Null), Null, Null)) = 'TRUE'";
  21. $query2 = "SELECT * FROM SIG_ANT.Ftth_Mn_Zapm_Partielle";
  22. $query3 = "Select count(*) From SIG_ANT.Ftth_Mn_Zapm_Partielle";
  23. $query = $query1;
  24. $stid = oci_parse($conn, $query);
  25. if (!$stid) {
  26. echo '<div style="color:red;">';
  27. $e = oci_error($conn); // Pour les erreurs oci_parse, passez le gestionnaire de connexion
  28. trigger_error(htmlentities($e['message']), E_USER_ERROR);
  29. echo '</div>';
  30. }
  31. $r = oci_execute($stid);
  32. if (!$r) {
  33. echo '<div style="color:red;">';
  34. $e = oci_error($stid); // Pour les erreurs oci_execute, passez le gestionnaire de connexion
  35. print htmlentities($e['message']);
  36. print "\n<pre>\n";
  37. print htmlentities($e['sqltext']);
  38. printf("\n%".($e['offset']+1)."s", "^");
  39. print "\n</pre>\n";
  40. echo '</div>';
  41. }
  42. echo "<table border='1'>\n";
  43. while ($row = oci_fetch_array($stid, OCI_BOTH)) {
  44. echo "<tr>\n";
  45. foreach ($row as $item) {
  46. echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "") . "</td>\n";
  47. }
  48. echo "</tr>\n";
  49. }
  50. echo "</table>\n";
  51. ?>