Created
December 14, 2013 08:07
-
-
Save thecfguy/7956736 to your computer and use it in GitHub Desktop.
Many-to-Many ColdFusion/ColdBox ORM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cfcomponent output="false"> | |
| <cfproperty name="tbl1Service" inject="entityService:tbl1" scope="variables"> | |
| <cfproperty name="tbl3Service" inject="entityService:tbl3" scope="variables"> | |
| <cffunction name="index" access="public" returntype="void" output="false"> | |
| <cfargument name="event" type="any"> | |
| <cfscript> | |
| var objT1 = tbl1Service.new({"col1":"new"}); | |
| var objT3 = tbl3Service.new({"column2":'New'}); | |
| objT1.addTbl3(objT3); | |
| tbl1Service.save(objT1); | |
| ormflush(); | |
| var objT1 = tbl1Service.getAll(); | |
| var objT3 = tbl3Service.getAll(); | |
| writeDump(objT1); | |
| writeDump(objT3); | |
| </cfscript> | |
| </cffunction> | |
| <cffunction name="deletetbl1" access="public" returntype="void" output="false"> | |
| <cfargument name="event" type="any"> | |
| <cfscript> | |
| tbl1Service.delete(tbl1Service.get(29)); | |
| abort; | |
| </cfscript> | |
| </cffunction> | |
| </cfcomponent> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component name="tbl1" persistent='true' accessors="true"{ | |
| property name="id" fieldtype="id" generator="increment"; | |
| property name="col1"; | |
| property name="col2"; | |
| property name="tbl3s" cascade="all-delete-orphan" fieldtype="many-to-many" cfc="tbl3" type="array" linktable="tbl13link" | |
| fkcolumn="tbl1id" inversejoincolumn="tbl3id" singularname="tbl3"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| component name="tbl3" persistent='true' accessors="true"{ | |
| property name="id" generator="increment"; | |
| property name="column2"; | |
| property name="tbl1s" fieldtype="many-to-many" cfc="tbl1" type="array" linktable="tbl13link" | |
| fkcolumn="tbl3id" inversejoincolumn="tbl1id" singularname="tbl1" inverse="true"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment