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

  1. #1

    Default mySQL and Array

    Hi all-

    I have defined an array using:

    <cfset notesattached = ArrayNew(1)>

    and added some data like this:

    <cfset notesattached[1] = 4>
    <cfset notesattached[2] = 8>

    But I can't figure out how to transfer #notesattached# to an SQL database; it
    says that it is a complex value.

    I've searched but haven't found my answer. Any help would be appreciated.

    Thanks,
    Adam

    adamjbecker Guest

  2. Similar Questions and Discussions

    1. Mysql result to array
      I have this query, it gives the suspected information in myphpadmin: select listid, count(*) from table1 group by listid How do I put this the...
    2. Array of Dates from MYSQL?...
      This has been puzzelling me for a couple of weeks now, and just can't figure it out. Does anyone know how to return an array of dates from MySQL...
    3. HOW TO -- ARRAY UPDATE MYSQL
      HI ALL, I want to update a mulitple row from a HTML Table to MYSQL Database. L1 V1 T1 L2 V2 V2 L3 V3 V3 Any help in this regard is much...
    4. php mysql array question
      I use the PEAR db http://pear.php.net/manual/en/package.database.php This returns arrays - examples here...
    5. [PHP] php mysql array question
      > Is there any php function to pull a query into an array? I know there is a loop looking used There's no PHP function to do so. Some...
  3. #2

    Default Re: mySQL and Array

    Insert each element into a record/field. individually. The details depend on
    what you are trying to do.

    Originally posted by: adamjbecker
    Hi all-

    I have defined an array using:

    <cfset notesattached = ArrayNew(1)>

    and added some data like this:

    <cfset notesattached[1] = 4>
    <cfset notesattached[2] = 8>

    But I can't figure out how to transfer #notesattached# to an SQL database; it
    says that it is a complex value.

    I've searched but haven't found my answer. Any help would be appreciated.

    Thanks,
    Adam



    Dan Bracuk Guest

  4. #3

    Default Re: mySQL and Array

    I'm trying to make it so that I can insert multiple numbers into one field of a mySQL database, and then retrieve the individual numbers dynamically.

    Hope that made sense.

    Adam
    adamjbecker Guest

  5. #4

    Default Re: mySQL and Array

    It makes sense to the extent that I understand your question. It doesn't make
    sense to the extent that you think you will be able to actually use the numbers
    once you stuff them into a single field of a single record.

    But, if you insist, make sure the field is text. Then insert
    '#arraytolist(yourarray)#'. Your numbers will be separated by commas.

    Originally posted by: adamjbecker
    I'm trying to make it so that I can insert multiple numbers into one field of
    a mySQL database, and then retrieve the individual numbers dynamically.

    Hope that made sense.

    Adam



    Dan Bracuk Guest

  6. #5

    Default Re: mySQL and Array

    It sounds like you're essentially trying to store a comma-delimited list of
    values in a single column. This is a bad design for a number of reasons, one
    of which is that it is very difficult to work with. If a single record in your
    main table can have zero or more "notes" a better design might be to store the
    notes in a separate table. For example, let's say the notes pertained to
    records in an "accounts" table:

    ACCOUNTS

    AccountID | AccountCode
    ---------------------------------
    1 | ABC
    ---------------------------------
    2 | EFG
    ---------------------------------
    3 | XYZ
    ---------------------------------

    NOTES

    NotesID | AccountID | Description
    ----------------------------------------------------
    1 | 1 | Created ABC account for ...
    ----------------------------------------------------
    2 | 1 | Changed information for ......
    ----------------------------------------------------
    3 | 2 | Opened EFG account for ......
    ----------------------------------------------------
    4 | 3 | Opened new account for .....
    ----------------------------------------------------
    5 | 1 | Updated XYZ address .....
    ----------------------------------------------------



    mxstu 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