Automated sql-queries

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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' <----...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default Re: 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.
    Something like this:
    <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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139