Created
July 18, 2014 19:19
-
-
Save abramadams/23d8fbaa128770ca354d to your computer and use it in GitHub Desktop.
Simple CF-ORM one-to-one example
This file contains 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 { | |
this.name = hash(getCurrentTemplatePath()); | |
this.sessionManagement = true; | |
this.sessionTimeout = CreateTimeSpan(0, 1, 0, 0); | |
this.ormenabled = true; | |
this.mappings['/'] = expandPath('.'); | |
this.datasource = 'sandbox'; | |
this.ormsettings = { | |
datasource = 'sandbox', | |
cfclocation = '/', | |
logsql = 'false', | |
dbcreate = 'dropcreate' | |
}; | |
} |
This file contains 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
<cfscript> | |
man = new model.man(); | |
man.setFirst_Name( 'Adam' ); | |
man.setLast_Name( 'Godson' ); | |
writeDump( var=[ man, man.hasWife() ], keys=20,top=3); | |
man.setWife( new model.wife(first_name="Eve", maiden_name="N/A", man = man) ); | |
writeDump( var=[ man, man.hasWife() ], keys=20,top=3); | |
entitySave( man ); | |
ormFlush(); | |
</cfscript> |
This file contains 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 persistent="true" table="man"{ | |
property name="ID" ormtype="integer" type="numeric" fieldtype="id" generator="identity" unique="true"; | |
property name="First_Name" type="string"; | |
property name="Last_Name" type="string"; | |
property name="wife" fieldtype="one-to-one" cfc="wife" column="wife_ID" mappedby="ID" cascade="all"; | |
} |
This file contains 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 persistent="true" table="wife"{ | |
property name="ID" ormtype="integer" type="numeric" fieldtype="id" generator="identity" unique="true"; | |
property name="First_Name" type="string"; | |
property name="Maiden_Name" type="string"; | |
property name="man" inverse="true" fieldtype="one-to-one" cfc="man" fkColumn="wife_ID" cascade="all"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment