473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to store multidimensional array in database?

rahulephp
Hi there,

can you please help me?

i have data in array and i want to insert it in a single table.
structure of table and array to be store is shown below:

Please let me know how to store this array in database?

Database Structure:



array-structure



database-Browse



Let me know any solution for this?
Thanks in anticipation
Dec 8 '09 #1
5 4649
hsriat
1,654 Expert 1GB
Make a different table for temp_property, with primary key as (temp_id, temp_property_id) using foreign key (temp_id) with fields (name, add, size, price, detail)

If there's no unique id for every property, then make one.
Dec 8 '09 #2
Thanks for your reply but i did this in another way using serialize and unserialize

Solution:

Expand|Select|Wrap|Line Numbers
  1. //sample
  2. $temp1 = serialize ($exarray);
  3. and then store $temp1 in batabase field.
  4. (recommend to  keep datatype of that field as text)
  5.  
  6. While fetching the data, again make it unserialize  
  7. and you will get your original array
  8. Like this
  9. $exarray = unserialize ($temp1);
  10.  
thanks again for your time
Dec 9 '09 #3
hsriat
1,654 Expert 1GB
If each property has its own name, ad, size, price & detail (as I suppose), I'd still recommend you to make a different table. You will find it useful later on.
Dec 10 '09 #4
kovik
1,044 Expert 1GB
serialize() and unserialize() are in the language primarily for session handling, so that you can save the $_SESSION array. This can be saved in the database since the $_SESSION array should not be limited in the types of fields that it can have.

However, for pretty much everything else, this is not the case. Session data is like file data. But, data that has specific properties should be inputted in the database with each property as it's own column and each instance as its own row.


Otherwise, what is the point of even having columns in database tables?
Dec 11 '09 #5
I would like to say Thanks to all of you for this great discussion.
Your replied posts are really very appreciating.

I think we need to close our discussion here.
Thanks again
Dec 11 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
2
by: chris | last post by:
Hi there, I created a Multidimensional array of labels Label lblMultiArray = new Label { {Label3, LblThuTotal}, {Label4,LblFriTotal} }; Now I would like to compare the values in the array,...
3
by: BobbyS | last post by:
I am trying to develop a multidimensional array for use of searching a very large database. I understand the concept of one and two dimensional arrays but this project would include up to 12 or 13...
2
by: BB | last post by:
Hello, I have a HTML form containing multidimensional selects listing equipments and their quantitites. This allow the users to select the kind of equipment and quantitites they would like to...
3
by: luftikus143 | last post by:
Hi there, I need to store three pieces of data - a result of a SQL query - in a multidimensional array, but don't really succeed. Sometimes it works, but then the output doesn't work accordingly....
9
by: JackpipE | last post by:
I need to create multidimensional array with arrays inside of it. database name | value1 | value2 john | red | 45 john | red | 56 john | yellow | 11 mike | blue | 23 mike | black | 41
5
by: LittleCake | last post by:
Hi All, I have a multidimensional array where each sub-array contains just two entries, which indicates a relationship between those two entries. for example the first sub-array: =Array ( =30...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.