Ask a Question related to Coldfusion Database Access, Design and Development.
-
adamjbecker #1
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
-
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... -
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... -
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... -
php mysql array question
I use the PEAR db http://pear.php.net/manual/en/package.database.php This returns arrays - examples here... -
[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... -
Dan Bracuk #2
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
-
adamjbecker #3
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
-
Dan Bracuk #4
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
-
mxstu #5
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



Reply With Quote

