This works great in Microsoft SQL server but what about MYSQL?
OK now I have 2 set's of code. More Database Support means more code but ColdFusion should = less code. Here is where the ORM can make this sort of thing a breeze:
So this 1 line of code :
can now replace:
Here is the code used for testing. With the ORM is simply a matter of creating an empty datasource with the database of your choice setting the dialect in Application.cfc and the ORM will even make the table for you you don't even need to load up Enterprise manager or phpmyadmin. I tested this on both MSSQL and MYSQL.
index.cfm

NewsItem.cfc

Application.cfc

The final result:

Oh and here is the link to the excellent docs at Adobe
Also make sure if you write your own constructors to specify default values or the ORM will cause some errors about not passing in values when it creates the objects behinds the scenes.
5 comments: