Author | Topic: Small helper functions for conneciton strings | |
---|---|---|
Sander Elias | Small helper functions for conneciton strings on Fri, 27 Mar 2015 15:35:50 +0100 Hi all, As I was really annoyed by the connection string manipulation all the time, I wrote this small helper functions perhaps it is of some use to someone: function connectSettings() local oSet := dataObject():new() in this sample I set the needed info from strings in a real project, you should read it from a configuration oSet:DBE := "pgdbe" oSet:SERVER := "LocalHost" oSet:UID := "postgres" oSet:PWD := "postgres" oSet:DB := "xppsamples" oSet:defineMethod("asString","_connectSettingsToString") return the connection as an easy to use dataObject the asString method will return a connection string as needed by all the SQL and DACsession stuff. return oSet function _connectSettingsToString(self) local aMembers := self:classDescribe(CLASS_DESCR_MEMBERS) local cRet := "" aEval(aMembers,{|e|cRet += e[1] + '=' + self:&(e[1]) + ";"}) return cRet Regards Sander Elias -------------------------------------------- also a member off the XXP (http://www.xxp.nl) |