Hi,
I have two tables as post and gallery, and i have made a relationship gallery to post table.
My requirement is,
When user upload content it store in the post table(content field) ,
If user upload the images are video i want to store the images/video name in, gallery table and the gallery id refers to the post table. I dont know how to do it. please any one help me?
post table:
[sql]CREATE TABLE IF NOT EXISTS post
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id
bigint(20) unsigned NOT NULL,
gallery_id
bigint(20) unsigned NOT NULL,
content
longtext,
photo
varchar(128) DEFAULT NULL,
video
varchar(128) DEFAULT NULL,
created
timestamp NULL DEFAULT NULL,
updated
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id
),
KEY fk_forum_post_user
(user_id
),
KEY fk_forum_post_gallery
(gallery_id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
ALTER TABLE post
ADD CONSTRAINT fk_post_gallery
FOREIGN KEY (gallery_id
) REFERENCES gallery
(id
) ON DELETE CASCADE ON UPDATE CASCADE,[/sql]
gallery table
[sql]CREATE TABLE IF NOT EXISTS gallery
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id
bigint(20) unsigned NOT NULL,
type
int(11) NOT NULL DEFAULT ‘1’ COMMENT ‘1- Photo, 2-Video, 3-Documents, 4-Unknown’,
profile_picture
varchar(50) DEFAULT NULL,
forum_image
varchar(200) DEFAULT NULL,
forum_video
varchar(200) DEFAULT NULL,
forum_video_link
varchar(200) DEFAULT NULL,
created
timestamp NULL DEFAULT NULL,
updated
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id
),
KEY fk_gallery_user
(user_id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=60 ;[/sql]
is any other idea is to do or how can i move forward?