this.datasource versus this.ormsettings.datasource

This probably falls into the obvious category, but if you are using ORM and have code that sets the datasource in the ormsettings, it will not apply to basic cfquery calls.

//Application.cfc this.ormEnabled=true; this.ormSettings.datasource="monkeypower"; //foo.cfc var q = new com.adobe.coldfusion.query(); q.setSQL("select mediatype from media where media like :search"); var results = q.execute().getResult(); //ERROR!

But - if you set this.datasource, it applies to both your cfquery calls as well as your ORM calls.

//Application.cfc this.datasource="monkeypower"; this.ormEnabled=true; //foo.cfc var q = new com.adobe.coldfusion.query(); q.setSQL("select mediatype from media where media like :search"); var results = q.execute().getResult(); //HAPPY MONKEYS!!

I suppose you could use different values for each, but I'd bet most people are using one DSN and probably still use a few "basic" queries even when making use of ORM.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments