Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

data.cfm 3.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  1. <cfscript>
  2. // Query 1: Print all the projects in which a specified student is involved
  3. function getProjectsForStudent(studentID) {
  4. var projects = [];
  5. var projectQuery = new query(datasource="task");
  6. var sql = "SELECT pname FROM Project WHERE pid IN (SELECT pid FROM Assigned WHERE sid = ?)";
  7. projectQuery.setSQL(sql);
  8. var result = projectQuery.execute([studentID]);
  9. while (result.next()) {
  10. arrayAppend(projects, result.pname);
  11. }
  12. result.close();
  13. return projects;
  14. }
  15. // Query 2: Print all the people working on a specified project
  16. function getPeopleForProject(projectID) {
  17. var people = [];
  18. var projectAllQuery = new query(datasource="task");
  19. var sql = "SELECT sname FROM Student WHERE sid IN (SELECT sid FROM Assigned WHERE pid = ?)";
  20. projectAllQuery.setSQL(sql);
  21. var result = projectAllQuery.execute([projectID]);
  22. while (result.next()) {
  23. arrayAppend(people, result.sname);
  24. }
  25. result.close();
  26. return people;
  27. }
  28. // Query 3: Print all the projects supervised by a specified faculty within a specified time range
  29. function getProjectsForFacultyWithinTimeRange(facultyID, startDate, endDate) {
  30. var projects = [];
  31. var facultyQuery = new query(datasource="task");
  32. var sql = "SELECT pname FROM Project WHERE pi = ? AND sdate >= ? AND edate <= ?";
  33. facultyQuery.setSQL(sql);
  34. var result = facultyQuery.execute([facultyID, startDate, endDate]);
  35. while (result.next()) {
  36. arrayAppend(projects, result.pname);
  37. }
  38. result.close();
  39. return projects;
  40. }
  41. </cfscript>
  42. <!--- Output section for messages --->
  43. <div id="output">
  44. <cfoutput>
  45. <!--- Check if a message is set and display it --->
  46. <cfif structKeyExists(url, "message")>
  47. <p>#url.message#</p>
  48. </cfif>
  49. </cfoutput>
  50. </div>
  51. <!--- Form for executing different queries and creating a new student --->
  52. <form id="studentServiceForm" action='/create' method="post">
  53. <!-- Form for creating a new student -->
  54. <!-- Input fields for student information -->
  55. <label for="sname">Name:</label>
  56. <input type="text" name="sname" id="sname"><br>
  57. <label for="major">Major:</label>
  58. <input type="text" name="major" id="major"><br>
  59. <label for="level">Level:</label>
  60. <input type="text" name="level" id="level"><br>
  61. <label for="byear">Birth Year:</label>
  62. <input type="text" name="byear" id="byear"><br>
  63. <!-- Button to create a new student -->
  64. <button type="submit" name="method" value="createStudent">Create New Student</button><br>
  65. </form>
  66. <form action="" method="post">
  67. <!-- Input field for student name -->
  68. <label for="sname">Student Name:</label>
  69. <input type="text" id="sname" name="SNAME"><br>
  70. </form>
  71. <form method="post" action="/projects">
  72. <!-- Query 2: People for Project -->
  73. <input type="text" name="projectID" placeholder="Enter project ID">
  74. <button type="submit" name="query" value="query2">Query 2: People for Project</button><br>
  75. </form>
  76. <form method="post" action="/faculty">
  77. <!-- Query 4: Get all students -->
  78. <button type="submit" name="query" value="getAllStudents">Query 4: Get all students</button><br>
  79. </form>
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...