Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8244619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:54:52+00:00 2026-06-07T21:54:52+00:00

I am working on a CMS in Codeigniter and it has the usual fields

  • 0

I am working on a CMS in Codeigniter and it has the usual fields like title, post content, etc (the page is similar to WordPress in this way).

I have an image uploader on the page that saves the image via ajax to a MySQL table with basic fields such as image_id, path, size.

There is another table that stores the relationship between an item and an image that requires both an item_id and an image_id.

The problem I have is that the item_id is not known until the page is created/saved. So if a user goes to the Create Post page and uploads an image from there, I can’t add the relationship since I don’t have an item_id yet.

Some things I am considering:

  • Every time someone goes to the Create Post page, it automatically creates a blank post in the MySQL table with just the item_id and storing it in a hidden field. The problem I have with this is the database could get filled with a lot of empty posts if a person just clicks Create Post but never fills it out.

  • Saving the images in the images table, but also save an array of all of their ids for when the Create button is clicked. When that button is click, then add the image relationships.

  • Hide the image uploader until the post title is filled out, which triggers a page save

WordPress seems to have solved this but I’m not sure what it does?

Anyone have any better suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:54:54+00:00Added an answer on June 7, 2026 at 9:54 pm

    I would say to structure your images table so that it doesn’t require a reference to a specific post. Put image-post relationships in a separate table. On your “compose post” screen, have the image uploader return the ID of the newly-inserted image, and when you submit the post, add the new post ID and the image ID to the table for image-post relationships. This also gives you more flexibility to do things like link to one image in multiple posts.

    — edit: upon re-reading, it sounds like this is already how you’re storing them. If so, then there shouldn’t be a problem. Just add the image-post relationship at the time the post is submitted. If you’re worried about orphaned images, see below. —

    You’re right that this could lead to orphan images, if someone uploads an image and then closes the window without making a post. I wouldn’t worry about the images table “filling up,” though. MySQL tables can have millions of rows and still perform well.

    If you’re concerned about collecting unused image files, you could have a periodic maintenance job that removes image files (and the associated table entries) if the upload date is older than, say, 1 week, and the image isn’t associated with any posts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a CMS with CodeIgniter and I would like to make an
I'm working on a CMS system that receives urls like this: /parent1/parent2/child/ Now it's
I'm working on wordpress CMS website. Basically I want this website in 2 different
My web development experience has mostly been setting up a CMS like Wordpress or
I am working on a cms and there are some simple parameters like number
I am working on a CMS project using ASP.Net 3.5/Visual studio 2008.This is the
I'm working with a CMS that parses variables into content using placeholders, e.g. <td>
I am working with a CMS like system, phpBMS, which defines a certain way
I am working with a CMS for a web app in PHP, that has
I'm working on a web application in Codeigniter. I'd like to integrate the functionality

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.