Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/8e471debc1d266e8c43ecaa0a2fc5940 to your computer and use it in GitHub Desktop.
Save trycf/8e471debc1d266e8c43ecaa0a2fc5940 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfoutput>
<!--- Abaikan cara pembuatan tabel di ColdFusion tanpa menggunakan database --->
<cfset tblemployee = queryNew("emp_id, emp_name, pos_id")>
<cfset queryAddRow(tblemployee, 5)>
<cfset querySetCell(tblemployee, "emp_id", "1", 1)>
<cfset querySetCell(tblemployee, "emp_name", "Ben", 1)>
<cfset querySetCell(tblemployee, "pos_id", "3", 1)>
<cfset querySetCell(tblemployee, "emp_id", "2", 2)>
<cfset querySetCell(tblemployee, "emp_name", "Ana", 2)>
<cfset querySetCell(tblemployee, "pos_id", "3", 2)>
<cfset querySetCell(tblemployee, "emp_id", "3", 3)>
<cfset querySetCell(tblemployee, "emp_name", "Sarah", 3)>
<cfset querySetCell(tblemployee, "pos_id", "1", 3)>
<cfset querySetCell(tblemployee, "emp_id", "4", 4)>
<cfset querySetCell(tblemployee, "emp_name", "Bob", 4)>
<cfset querySetCell(tblemployee, "pos_id", "2", 4)>
<cfset querySetCell(tblemployee, "emp_id", "5", 5)>
<cfset querySetCell(tblemployee, "emp_name", "Aris", 5)>
<cfset querySetCell(tblemployee, "pos_id", "4", 5)>
<cfset tblposition = queryNew("pos_id, pos_name")>
<cfset queryAddRow(tblposition, 4)>
<cfset querySetCell(tblposition, "pos_id", "1", 1)>
<cfset querySetCell(tblposition, "pos_name", "Board of Director", 1)>
<cfset querySetCell(tblposition, "pos_id", "2", 2)>
<cfset querySetCell(tblposition, "pos_name", "Deptarement Head", 2)>
<cfset querySetCell(tblposition, "pos_id", "3", 3)>
<cfset querySetCell(tblposition, "pos_name", "Accountant", 3)>
<cfset querySetCell(tblposition, "pos_id", "4", 4)>
<cfset querySetCell(tblposition, "pos_name", "Sales", 4)>
<cfdump var="#tblemployee#" label="Table Employee">
<cfdump var="#tblposition#" label="Table Posisi">
<!--- Abaikan sampai di titik ini --->
<!--- Soal 1 --->
<!--- Bikin Tampilan Report seperti ini
| Employee ID | Employee Name | Position Name |
| 2 | Ana | Accountant |
| 1 | Ben | Accountant |
| 3 | Sarah | Board of Director |
| 4 | Bob | Department Head |
| 5 | Aris | Sales |
--->
<cfquery name="qTableGw" dbtype="query">
select emp.emp_id, emp.emp_name, pos.pos_name
from tblemployee emp, tblposition pos
where emp.pos_id = pos.pos_id
</cfquery>
<cfdump var="#qTableGw#">
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment