Enter code here./**
* I am a new Model Object
*/
component singleton accessors="true"{
// Dependency Injection
property name="dsn" inject="coldbox:datasource:coldbox_test";
/**
* Constructor
*/
ContactDAO function init() {
return this;
}
query function getAll(){
var q = new Query(datasource="#dsn#",sql="SELECT * FROM contacts");
return q.execute().getResult();
}
query function getContact(required contactID){
var q = new Query(datasource="#dsn#",sql="SELECT * FROM contacts WHERE contact_id = :contactID");
q.addParam(name="contactID",value=arguments.contactID,cfsqltype="cf_sql_numeric");
return q.execute().getResult();
}
/*... ALL OTHER METHODS HERE FOR CRUD ....*/
}..
datasource = { coldbox_test = {name="your_dsn"} };
--------- Original Message ---------
Subject: [coldbox:25927] New to ColdBox
From: "Nkonye Oyewusi" <tall...@gmail.com>
Date: 9/5/16 10:44 am
To: "ColdBox Platform" <col...@googlegroups.com>
Hello,
I'm trying to create a simple CRUD app in ColdBox.
I have in my handler Contacts.cfc with all the methods.
I have in my models Contacts.cfc, ContactsService.cfc and ContactsDAO.cfc.
The problem is that in ContactsDAO.cfc, ColdBox does not recognise the DSN, even though it has been created in myCFAdministrator. I get the following erre:Builder.DSLDependencyNotFoundException
The code is as follows:
Enter code here./**
* I am a new Model Object
*/
component singleton accessors="true"{
// Dependency Injection
property name="dsn" inject="coldbox:datasource:coldbox_test";
/**
* Constructor
*/
ContactDAOfunction init(){
returnthis;
}
query function getAll(){
var q =newQuery(datasource="#dsn#",sql="SELECT * FROM contacts");
return q.execute().getResult();
}
query function getContact(required contactID){
var q =newQuery(datasource="#dsn#",sql="SELECT * FROM contacts WHERE contact_id = :contactID");
q.addParam(name="contactID",value=arguments.contactID,cfsqltype="cf_sql_numeric");
return q.execute().getResult();
}
/*... ALL OTHER METHODS HERE FOR CRUD ....*/
}..
Any ideas as to how to fix this?
Thanks.
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/8a0aa143-4fe2-429f-9bab-3e9943cef98c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.