MySQL Forums
Forum List  »  Newbie

Using Associative Arrays as a field value?
Posted by: Jesse Albanese
Date: July 13, 2005 02:22AM

I was brainstorming the other night, setting up the structure of tables I want to use on my new project (something I am doing to help me learn and grow a bit more comfortable with MySQL and PHP). Here's a brief look at the brainstorm for one of the tables I wanted to implement:


[* denotes NOT NULL]
[+ denotes indexed]

Table: BOARD_POST_STATS
+*post_id (ten digits)
*thread_id (eight digits) [ID of thread post belongs to]
*post_number (five digits) [placement of post in thread]
*board_id (three digits (or maybe varchar))
*read (six digits) [number of times read]
*user_id (six digits) [ID of user who posted]
*reported_new (four digits) [number of times post has
---------------------------------been reported that Mod has
---------------------------------HAS read]
*reported_old (four digits) [number of times post has
--------------------------------been reported that Mod HAS
--------------------------------read]
*post_content (text) [the actual post]
*post_date (datetime)
*edits (array? datetime, user_id, content)



The last item, "edits," was going to be an array of associative arrays containing three values; the date of the edit, the user_id of whomever was editing, and the content previous to editing. This would enable me to have an "Edit History" for posts (and thus allowing Moderators for the board to view what was in a post that was edited by a user from later functions I planned on building).

However, I am fairly new to MySQL, and the things I have read don't seem to point me in the right direction of doing what it is that I want to do. I want a column on the "BOARD_POST_STATS" table to be formatted as an array for each entry. For each edit existing, I want to add an element to that array; this element would be an associative array itself, consisting of three different values.

For example

post_id: 1234567890
thread_id: 12345678
post_number: 12345
board_id: 123
read: 123456
user_id: 123456
reported_new: 1234
reported_old: 1234
post_content: "Blah blah blah"
post_date: [date]
edits:
--1 =>
----date => [date]
----user_id => 123456
----content => "Bleh bleh bleh"
--2 =>
----date => [date]
----user_id => 654321
----content => "Blarg"
--3 =>
----date => [date]
----user_id => 456789
----content => "Blammity"



Get what I mean?

Options: ReplyQuote


Subject
Written By
Posted
Using Associative Arrays as a field value?
July 13, 2005 02:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.