Ask a Question related to Coldfusion Database Access, Design and Development.
-
marksta80 #1
Automated sql-queries
Hello cf-pro's
I'm quite new to coldfusion (accustomed to php), so this might be the reason
of my problems :) But let's have a look at my idea (if you want to)
I want to create a Component that creates sql statments
e.g. A method called "generateInsert" with the parameters "tableName" and an
assosiative Array (or something similar). The keys and values of the array are
not known by the component. The component should now be able to generate a SQL
Statment like this:
INSERT INTO #tableName# (...list of all array keys...) VALUES (.... list of
all array values...)
I'm able to create a component with the parameters, but how to I get e.g.
Form-Values into the needed array (or struct) and afterwards, how to i get them
out again.
I'm pretty sure I'm not the only one having this idea, so maybe you might even
have found such a component, unfortunately I haven't yet.
I'm really looking forward to your tipps
Markus
marksta80 Guest
-
Automated PDF Creation
Many years ago we used to have a server that ran Distiller and we dragged and dropped files onto the server and PDFs were created. Then Adobe wrote... -
Queries Of Queries Single Quote Problem
When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----... -
Automated updates
Hi, I am currently a university student in the UK and am studying business computing degree. For my dissertation I am researching the use of... -
Automated tasks
Hi, I have an auction site running. Now I want the auction to be able to automatically send a mail msg to the seller after it expires. How do I... -
Automated Filelist.
Hi! I want to build a PHP-Site, wich lists some downloadable files in some directories from our internet server. Can anyone tell me some... -
Neculai Macarie #2
Re: Automated sql-queries
> Hello cf-pro's
reason>
> I'm quite new to coldfusion (accustomed to php), so this might be thean> of my problems :) But let's have a look at my idea (if you want to)
>
> I want to create a Component that creates sql statments
>
> e.g. A method called "generateInsert" with the parameters "tableName" andare> assosiative Array (or something similar). The keys and values of the arraySQL> not known by the component. The component should now be able to generate aof> Statment like this:
>
> INSERT INTO #tableName# (...list of all array keys...) VALUES (.... listthem> all array values...)
>
> I'm able to create a component with the parameters, but how to I get e.g.
> Form-Values into the needed array (or struct) and afterwards, how to i getSomething like this:> out again.
<cfset fieldsToInsert = StructNew()>
<cfloop collection="#form.fieldnames#" item="field">
<cfset fieldsToInsert[field] = form[field]>
</cfloop>
#generateInsert('table', fieldsToInsert)#
Inside the generateInsert function:
<cfloop collection="#Attributes.fiieldsToInsert#" item="field">
#Attributes.fiieldsToInsert[field]#
</cfloop>
--
<mack />
Neculai Macarie Guest



Reply With Quote

