saveRecord Behaviour Understanding Problem

8 views
Skip to first unread message

Mark

unread,
Apr 23, 2011, 6:22:38 AM4/23/11
to DataMgr
Hi, I just started using DataMgr and have a little problem with
understanding what saveRecord does. I tought that if I do not pass a
value for the primary key it automatically inserts a now record - but
what it does is updating the record for the primary key. So when does
saveRecord inserts a new record ?

An other question is. Is it posssible to map the structure keys to
column names inside DataMgr. So that one does not have to change every
part of code if a column name changes.

Thanks for your help.

Mark

Steve Bryant

unread,
Apr 25, 2011, 3:08:59 PM4/25/11
to dat...@googlegroups.com
Mark,

Terribly sorry about the long-delay in getting your message approved.
Somehow I got out of the habit of checking my GMail.

Great question on saveRecord and something I probably have not made
clear enough.

Check out the "OnExists" section under "insertRecord":
http://www.bryantwebconsulting.com/docs/datamgr/save-data.cfm

The upshot of this is that saveRecord will update a record based
either on primary key or if it finds an existing record matching the
given data. What you want is insertRecord() with OnExists="save". I
realized this was a bit confusing after I already had a whole bunch of
code dependent on the current set up.

It isn't currently possible to map structure keys to column names, but
I love that idea. I'll have to ponder how best to do that. In the
meantime, if you (or any else) have any idea on how you would like
that to work, let me know.

Steve

Salvatore FUSTO

unread,
Apr 26, 2011, 3:18:19 AM4/26/11
to dat...@googlegroups.com
Mark,
i solved your second question in this way: i developed an abstract service
layer in which I inject dataMgr for database operations; in my object, I
have a custom tag attribute <cfproperty name... mapTo="myTable"/> so when I
have to persist my object I pass it to may service layer save() method,
where a new struct is defined and passed to insertRecord() or save Record().
Also, i define my object component with other custom attributes, one is for
cf componenent tag: <cfcomponent ... table="myTable"/> so I simply call the
service layer save(myObj) and it has all, from metadata, to save record in
the proper table with the proper mapping.
Hope been clear and usefull
salvatore

-----Messaggio originale-----
Da: dat...@googlegroups.com [mailto:dat...@googlegroups.com] Per conto di
Mark
Inviato: sabato 23 aprile 2011 12.23
A: DataMgr
Oggetto: [DataMgr] saveRecord Behaviour Understanding Problem

Thanks for your help.

Mark

--
You received this message because you are subscribed to the Google Groups
"DataMgr" group.
To post to this group, send email to dat...@googlegroups.com.
To unsubscribe from this group, send email to
datamgr+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/datamgr?hl=en.

Reply all
Reply to author
Forward
0 new messages