Table aliases I would like like to see done before column aliases. But column aliases would be great too. We have naving conventions for our DB tables that don't always line up perfectly with our CFC naming conventions. For example we like to use camel case for our objects (firstName) while the DBA uses underscores in the column names (first_name).

If I could vote I would vote for table aliases first the column aliases. :) Just my $.02.

--Kurt

On 2/9/06, Jared Rypka-Hauer < [EMAIL PROTECTED]> wrote:
Yeah, but that doesn't help in a case where someone like PayPal is forcing column names like... oh, lemme check the doco for a good one:

address_country_code = US
address_country = United States

Or this whole block here:
address_name = Jared Rypka-Hauer
address_street = 123 Sesame St.
address_city = Burnsville
address_state = MN
address_zip = 55121
address_country = United States
address_country_code = US
address_status = confirmed


Those are the names of fields that come in from PayPal either on the URL or in a form post (PDT = URL, IPN=POST data) and I either map them by hand (and when there's over 100 different varieties!) if they change or add to them... icky) or use a tool of some sort. I'm planning to add mappings to PayPalMX (I think) but for now the ability to set mappings from the incoming block of instanity to something more legit.


Something obviously has to be done to allow for the fact that data coming in for a new record is going to look like the above (which will be the column names in the DB) and set that data to the right fields in the object... something like:


<!--- where mappings has format mappings[oldName] = newName --->

<cfloop collection="mappings" item="i">

<cfif structKeyExists(arguments,i)>

<cfset myField = arguments[i]>

<cfelseif structKeyExists(arguments,mappings[i])>

<cfset myField = arguments[mappings[i]]>

</cfif>

</cfloop>


That would effectively grab the data from the incoming data block whether it was named by the DB convention (underscores?) or by the ORM convention (camelCase?). The only real question is where to put it...  perhaps in a setInstance() method? Dunno. I'd have to study that a bit more.


But... there's my 49 cents on the subject. :)


Laterz,

J


------------------------------------------------

Jared C. Rypka-Hauer

Continuum Media Group LLC

http://www.web-relevant.com

Member, Team Macromedia - ColdFusion


"That which does not kill me makes me stranger." - Yonah Schmeidler


On Feb 9, 2006, at 12:43 PM, Michael Lantz wrote:

Just so you are aware, you can use aliases when working with the table/view name, just not the field names.
 
This can be done in the config xml file by adding the 'alias="newtablename"' to the <object> tag.
 
Michael


From: [EMAIL PROTECTED] [ mailto:[EMAIL PROTECTED]] On Behalf Of Tormod Boga
Sent: Thursday, February 09, 2006 11:36 AM
To: [email protected]
Subject: Re: Reactor For CF Object Relational Mapping

I agree with both of you.. A thing like this would be great.
I have previously requested the feature of adding aliases to the table/object names, because I have to deal with tables named tblxxx too.. The code would look alot nicer if the generated objects had discarded the 'tbl' prefix (by giving it an alias).
Doing the same thing for columns would be great as well..


At 12:29 09.02.2006 -0600, you wrote:
I think this would be great as sometimes I have to use legacy named tables with the 'tbl' prefix.  I also like to name my tables in plural, "users", "orders", but I like to have my objects singular, "user", "order".  I also like to name my columns in the db with an underscore, but my methods are camelCase.  Of course, this probably adds a level of complexity that Doug may not want to attempt.


On 2/9/06, Miller, Ryan <[EMAIL PROTECTED]> wrote:
To follow up my questions on Views and in relation to the other discussion about only saving certain values.
 
Is adding some mapping capability to the config xml been discussed or planned? 
 
Or does this little community prefer doing it's mappings via Views?
 
I'm thinking about diving into the code to add support for something like this in the config xml
 
<object name="SomeClass" table="SomeTable">
  <fields>
    <field name="someID" column="ID" />
    <field name="name" column="some_name" />
  </fields>
</object>
 
I thought I'd just float the idea here to see if this has been discussed or tried already before jumping in with both feet.
 
Thanks,
Ryan Miller



--
Marlon

/ Tormod Boga
/ [EMAIL PROTECTED]



Reply via email to