Getting and Filtering Records in DataMgr
In working with a subcontractor, I realized that I have done a poor job so far in providing a simple example of getting and filtering records with DataMgr. DataMgr makes this task very easy, but it does require a little explanation.
Not really - the data argument takes a struct that tests for equality.
That being said, version 2.2 will have two feature that could help you out in that (one that could help you now):
I plan to add (and have working in a local dev copy) a "filters" feature which will allow you to define the operator used for a comparison.
Another feature for 2.2 is an argument in getRecords called "advsql". This will be a structure with keys for the different parts of a SQL statement (SELECT,FROM,WHERE,ORDER BY) that would allow to insert your own SQL into the SQL created by getRecords().
If you really need to use a LIKE operator with DataMgr now, you might try to use this feature as though it exists. It could be that the feature is in 2.1, but left as undocumented.
Good luck!
Thanks for responding so quickly! I am very impressed with DataMgr. I have been seriously evaluating various ORM tools for ColdFusion, but it seems like everything has some major drawback that is a deal-killer for me. DataMgr is amazingly simple, yet helpful. So, props to you for coming up with this great design. I think it is going to work for me. But the like feature is a critical one.
Do you know when the 2.2 is going to be available (approximately)? Could I be a beta tester for you?
Also. I noticed in your documentation on 2.1 that it mentioned the "advsql". Would it be possible for you to send a quick syntax example of using that in the getRecords() function?
Thanks again, and great work!
Thanks for the kind words.
I expect to have a blog entry covering advsql later this week. I also expect to announce a public Alpha release on DataMgr 2.2 soon (hopefully measured in days, not weeks). Given my goals, it may still be some time until it is feature-complete though.
Let me know if you have any more questions or run into any trouble.
Just after I sent it I looked into the datamgr.cfc file to see your comments there. Anyway, I was able to make it work using the following code. I assume this is the way that it was intended. Once again, nice design and great code comments.
<cfset advsql = structnew()>
<cfset advsql.where = "email like 'randy%'">
<cfset qUser = Application.appsecurity.datamgr.getrecords(tablename="users", advsql=advsql, fieldlist="username,userid,email")>
Thanks!