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

  • SEARCH
  • Home
  • 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 708151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:21:32+00:00 2026-05-14T04:21:32+00:00

I have two tables, content and images (and a ContentImages table for the one

  • 0

I have two tables, content and images (and a ContentImages table for the one to many relation, so that’s actually 3 tables).

The following code saves the relation (in the action > updateContentFromRequest() ):

$ids = $this->getRequestParameter('contentImages');  
if( isset($ids) ){
    $ImagesTable = Doctrine::getTable('Content')->getRelation('Images')->getTable();
    $associationName = Doctrine::getTable('Content')->getRelation('Images')->getAssociationTable()->getOption('name');
    $this->content->$associationName->delete();
    foreach ($ids as $id){
        $id = explode('/', $id);
        $this->content->get('Images')->add($ImagesTable->find($id));
    }}

I changed the model to include a sort field in the ContentImages table:

content_id
image_id
sort (numeric)

The sort number is simply that, a number (0,1,2,3 etc)

$sort = $this->getRequestParameter('contentImagesSort');

How do I save the sort number? I do not want to add a sort field to the Image table because that could create difficulties when images are re-used across more content items. When a content item is new I do not know the ID yet so I’m a bit stumped…

  • 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-05-14T04:21:33+00:00Added an answer on May 14, 2026 at 4:21 am

    You should add One to Many associations on your join Table, like:

    ContentImages:
      relations:
        Image:
          local: image_id
          foreign: id
        Content:
           local: content_id
           foreign: id
    

    As such, you will be able to query directly the join table like this :

    $q = Doctrine_Query::create()
      ->from('Content c')
      ->leftJoin('c.ContentImages ci')
      ->leftJoin('c.Images i')
      ->execute();
    

    Then you can access to ContentImages using

    $content->ContentImages->setSort('your sort');
    

    This should do the trick 🙂

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

Sidebar

Related Questions

I have two tables that have virtually identical content and very similar structure. They
If I have these two tables: <table> <tr> <td>Small Length Content</td> </tr> </table> <table>
I have two table cells, with dynamic content. Table cell one works fine, when
I have two tables that relates 1:n content --------- - id - title -
I have the following code. I have two background images for buttons - lightSquare.jpg
i have one question regarding URI! i have two tables in my content provider!
I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
I have two tables: table a ida valuea 1 a 2 b 3 c
I have an array of images, and two nib files. One nib file has
I have two tables which have a structure as follows: `content` (id, foreign_id, type,

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.